FetcherRequest
This commit is contained in:
@@ -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{}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user