Skip to content

Commit

Permalink
feat(kemono): Add q query param
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jun 3, 2024
1 parent 56c16c7 commit 20eea89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion internal/kemono/kemono.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ func postURL(host string, c Creator, p Post) *url.URL {
return u
}

func postAPIURL(host string, c Creator, page uint64) *url.URL {
func postAPIURL(host string, c Creator, page uint64, query string) *url.URL {
q := url.Values{}
q.Set("o", strconv.FormatUint(page*50, 10))
q.Set("q", query)
u := &url.URL{
Scheme: "https",
Host: host,
Expand Down
4 changes: 3 additions & 1 deletion internal/kemono/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ func postHandler(host string) http.HandlerFunc {
}
}

query := r.URL.Query().Get("q")

for page := range pages {
posts, err := fetchPostPage(r.Context(), postAPIURL(host, creator, page).String())
posts, err := fetchPostPage(r.Context(), postAPIURL(host, creator, page, query).String())
if err != nil {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
panic(err)
Expand Down

0 comments on commit 20eea89

Please sign in to comment.