-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhackernews.go
94 lines (90 loc) · 3.16 KB
/
hackernews.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package main
import (
"time"
)
var hackernewsIconURL = "https://emoji.slack-edge.com/T085AJH3L/hacker-news/0daae30bfa8eefc6.png"
type HackerNewsResponse struct {
Hits []HackerNewsResult `json:"hits"`
NbHits int `json:"nbHits"`
Page int `json:"page"`
NbPages int `json:"nbPages"`
HitsPerPage int `json:"hitsPerPage"`
ExhaustiveNbHits bool `json:"exhaustiveNbHits"`
ExhaustiveTypo bool `json:"exhaustiveTypo"`
Exhaustive struct {
NbHits bool `json:"nbHits"`
Typo bool `json:"typo"`
} `json:"exhaustive"`
Query string `json:"query"`
Params string `json:"params"`
ProcessingTimeMS int `json:"processingTimeMS"`
ProcessingTimingsMS struct {
AfterFetch struct {
Format struct {
Highlighting int `json:"highlighting"`
Total int `json:"total"`
} `json:"format"`
Total int `json:"total"`
} `json:"afterFetch"`
Fetch struct {
Scanning int `json:"scanning"`
Total int `json:"total"`
} `json:"fetch"`
Request struct {
RoundTrip int `json:"roundTrip"`
} `json:"request"`
Total int `json:"total"`
} `json:"processingTimingsMS"`
ServerTimeMS int `json:"serverTimeMS"`
}
type HackerNewsResult struct {
CreatedAt time.Time `json:"created_at"`
Title string `json:"title"`
URL string `json:"url"`
Author string `json:"author"`
Points int `json:"points"`
StoryText string `json:"story_text"`
CommentText string `json:"comment_text"`
NumComments int `json:"num_comments"`
StoryID int `json:"story_id"`
StoryTitle string `json:"story_title"`
StoryURL string `json:"story_url"`
ParentID int `json:"parent_id"`
CreatedAtI int `json:"created_at_i"`
RelevancyScore int `json:"relevancy_score"`
Tags []string `json:"_tags"`
ObjectID string `json:"objectID"`
HighlightResult struct {
Author struct {
Value string `json:"value"`
MatchLevel string `json:"matchLevel"`
MatchedWords []string `json:"matchedWords"`
} `json:"author"`
CommentText struct {
Value string `json:"value"`
MatchLevel string `json:"matchLevel"`
FullyHighlighted bool `json:"fullyHighlighted"`
MatchedWords []string `json:"matchedWords"`
} `json:"comment_text"`
StoryTitle struct {
Value string `json:"value"`
MatchLevel string `json:"matchLevel"`
MatchedWords []string `json:"matchedWords"`
} `json:"story_title"`
StoryURL struct {
Value string `json:"value"`
MatchLevel string `json:"matchLevel"`
MatchedWords []string `json:"matchedWords"`
} `json:"story_url"`
Title struct {
Value string `json:"value"`
MatchLevel string `json:"matchLevel"`
MatchedWords []string `json:"matchedWords"`
} `json:"title"`
URL struct {
Value string `json:"value"`
MatchLevel string `json:"matchLevel"`
MatchedWords []string `json:"matchedWords"`
} `json:"url"`
} `json:"_highlightResult"`
}