Documentation ¶
Index ¶
- func API(log restql.Logger, cfg *conf.Config) (fasthttp.RequestHandler, error)
- func CalculateStatusCode(queryResult domain.Resources) int
- func Debug(log restql.Logger) fasthttp.RequestHandler
- func Health(log restql.Logger, cfg *conf.Config) fasthttp.RequestHandler
- func NewRequestError(err error, status int) error
- func Respond(ctx *fasthttp.RequestCtx, data interface{}, statusCode int, ...) error
- func RespondError(ctx *fasthttp.RequestCtx, err error) error
- type Error
- type ErrorResponse
- type QueryResponse
- type StatementDebugging
- type StatementDetails
- type StatementMetadata
- type StatementResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateStatusCode ¶
CalculateStatusCode returns the greater status in all statement results to be used as the response status code. It applies the following normalization to statement result status codes:
0 => 500 204 => 200 201 => 200
func Debug ¶
func Debug(log restql.Logger) fasthttp.RequestHandler
Debug constructs a handler for profiling endpoints
func NewRequestError ¶
NewRequestError wraps a provided error with an HTTP status code. This function should be used when handlers encounter expected errors.
func Respond ¶
func Respond(ctx *fasthttp.RequestCtx, data interface{}, statusCode int, headers map[string]string) error
Respond write the information back to the client.
func RespondError ¶
func RespondError(ctx *fasthttp.RequestCtx, err error) error
RespondError translate the error and write it back to the client.
Types ¶
type Error ¶
Error is used to pass an error during the request through the application with web specific context.
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse is the form used for API responses from failures in the API.
type QueryResponse ¶
type QueryResponse struct { StatusCode int Body map[string]StatementResult Headers map[string]string }
QueryResponse represents the client format of the query result
func MakeQueryResponse ¶
func MakeQueryResponse(queryResult domain.Resources, debug bool) (QueryResponse, error)
MakeQueryResponse create a query execution response for the client.
type StatementDebugging ¶
type StatementDebugging struct { Method string `json:"method,omitempty"` URL string `json:"url,omitempty"` RequestHeaders map[string]string `json:"request-headers,omitempty"` ResponseHeaders map[string]string `json:"response-headers,omitempty"` Params map[string]interface{} `json:"params,omitempty"` RequestBody interface{} `json:"request-body,omitempty"` ResponseTime int64 `json:"response-time,omitempty"` }
StatementDebugging represents the client format of debugging information
type StatementDetails ¶
type StatementDetails struct { Status int `json:"status"` Success bool `json:"success"` Metadata StatementMetadata `json:"metadata"` Debug *StatementDebugging `json:"debug,omitempty"` }
StatementDetails represents the client format of the statement details
type StatementMetadata ¶
type StatementMetadata struct {
IgnoreErrors string `json:"ignore-errors,omitempty"`
}
StatementMetadata represents the client format of metadata
type StatementResult ¶
type StatementResult struct { Details interface{} `json:"details"` Result interface{} `json:"result,omitempty"` }
StatementResult represents the client format of the statement result