INNER CODE UNIT · Go
loadSchema
shurcooL/githubv4 · gen.go:63
func loadSchema(githubToken string) (schema interface{}, err error) {
req, err := http.NewRequest("GET", "https://api.github.com/graphql", nil)
if err != nil {
return nil, err
}
req.Header.Set("Authorization", "bearer "+githubToken)
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("non-200 OK status code: %v body: %q", resp.Status, body)
}
err = json.NewDecoder(resp.Body).Decode(&schema)
return schema, err
}