MCPcopy
hub / github.com/hasura/graphql-engine / GetHasuraInternalServerConfig

Method GetHasuraInternalServerConfig

cli/cli.go:222–247  ·  view source on GitHub ↗
(client *httpc.Client)

Source from the content-addressed store, hash-verified

220}
221
222func (c *ServerConfig) GetHasuraInternalServerConfig(client *httpc.Client) error {
223 var op errors.Op = "cli.ServerConfig.GetHasuraInternalServerConfig"
224 // Determine from where assets should be served
225 url := c.getConfigEndpoint()
226 ctx, cancelFunc := context.WithTimeout(context.Background(), 30*time.Second)
227 defer cancelFunc()
228 req, err := client.NewRequest("GET", url, nil)
229 if err != nil {
230 return errors.E(op, fmt.Errorf("error fetching config from server: %w", err))
231 }
232 r, err := client.Do(ctx, req, &c.HasuraServerInternalConfig)
233 if err != nil {
234 return errors.E(op, errors.KindNetwork, err)
235 }
236 defer r.Body.Close()
237
238 if r.StatusCode != http.StatusOK {
239 var horror hasuradb.HasuraError
240 err := json.NewDecoder(r.Body).Decode(&horror)
241 if err != nil {
242 return errors.E(op, errors.KindHasuraAPI, fmt.Errorf("error unmarshalling fetching server config"))
243 }
244 return errors.E(op, errors.KindHasuraAPI, fmt.Errorf("error fetching server config: %v", horror.Error()))
245 }
246 return nil
247}
248
249// HasuraServerConfig is the type returned by the v1alpha1/config API
250// TODO: Move this type to a client implementation for hasura

Callers 1

ValidateMethod · 0.80

Calls 5

getConfigEndpointMethod · 0.95
ErrorMethod · 0.95
NewRequestMethod · 0.80
DoMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected