FetcherRequest

This commit is contained in:
Zsolt Tasnadi
2026-01-20 08:31:59 +01:00
parent 8f51e6d981
commit 6be44be9bf
4 changed files with 66 additions and 16 deletions

View File

@@ -1,7 +1,6 @@
package lib
import (
"bytes"
"fmt"
"net/http"
)
@@ -26,14 +25,21 @@ type WikiFetcher struct {
func (f WikiFetcher) Fetch() []Entry {
q := `{"query":"{ pages { list(orderBy: UPDATED, orderByDirection: DESC, limit: 1){ path, updatedAt, title }}}"}`
wikiURL := fmt.Sprintf("%s/graphql", f.BaseURL)
req, _ := http.NewRequest("POST", wikiURL, bytes.NewBuffer([]byte(q)))
req.Header.Set("Authorization", "Bearer "+f.Token)
req.Header.Set("Content-Type", "application/json")
req := FetcherRequest{
BaseURL: f.BaseURL,
Path: "/graphql",
Method: http.MethodPost,
Headers: map[string]string{
"Authorization": "Bearer " + f.Token,
"Content-Type": "application/json",
},
Body: []byte(q),
}
var r WikiResponse
if err := getJSON(req, &r); err != nil {
if err := req.Run(&r); err != nil {
return []Entry{}
}