summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/handlers.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/api/handlers.go b/api/handlers.go
index d3a08fd..4299b74 100644
--- a/api/handlers.go
+++ b/api/handlers.go
@@ -3,6 +3,7 @@ package api
import (
"context"
"io"
+ "bytes"
"database/sql"
"errors"
"encoding/json"
@@ -228,14 +229,25 @@ func (h *Handler) GetArticle(w http.ResponseWriter, r *http.Request) {
}
baseURL := "https://api.enterprise.wikimedia.com/v2/structured-contents/" + url.QueryEscape(article)
- queryURL := baseURL + "?limit=1"
- req, err := http.NewRequestWithContext(ctx, "GET", queryURL, nil)
+ body, err := json.Marshal(map[string]any{
+ "filters": []map[string]string{
+ {"field": "in_language.identifier", "value": "en"},
+ },
+ })
+ if err != nil {
+ serverError(w, "could not build request")
+ return
+ }
+
+ req, err := http.NewRequestWithContext(ctx, "POST", baseURL, bytes.NewReader(body))
if err != nil {
serverError(w, "could not build request")
return
}
req.Header.Set("Authorization", "Bearer "+acct.AccessToken)
+ req.Header.Set("Content-Type", "application/json")
+ queryURL := baseURL
start := time.Now()
resp, err := http.DefaultClient.Do(req)