Documentation ¶
Index ¶
- func AppendCloseReason(ctx context.Context, reason string) context.Context
- func SendError(w http.ResponseWriter, code int, errors ...*gqlerror.Error)
- func SendErrorf(w http.ResponseWriter, code int, format string, args ...interface{})
- type GET
- type InitPayload
- type MultipartForm
- type Options
- type POST
- type Websocket
- type WebsocketError
- type WebsocketErrorFunc
- type WebsocketInitFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendCloseReason ¶ added in v0.15.0
func SendError ¶
func SendError(w http.ResponseWriter, code int, errors ...*gqlerror.Error)
SendError sends a best effort error to a raw response writer. It assumes the client can understand the standard json error response
func SendErrorf ¶
func SendErrorf(w http.ResponseWriter, code int, format string, args ...interface{})
SendErrorf wraps SendError to add formatted messages
Types ¶
type GET ¶
type GET struct{}
GET implements the GET side of the default HTTP transport defined in https://github.com/APIs-guru/graphql-over-http#get
func (GET) Do ¶
func (h GET) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor)
type InitPayload ¶
type InitPayload map[string]interface{}
InitPayload is a structure that is parsed from the websocket init message payload. TO use request headers for non-websocket, instead wrap the graphql handler in a middleware.
func GetInitPayload ¶
func GetInitPayload(ctx context.Context) InitPayload
GetInitPayload gets a map of the data sent with the connection_init message, which is used by graphql clients as a stand-in for HTTP headers.
func (InitPayload) Authorization ¶
func (p InitPayload) Authorization() string
Authorization is a short hand for getting the Authorization header from the payload.
func (InitPayload) GetString ¶
func (p InitPayload) GetString(key string) string
GetString safely gets a string value from the payload. It returns an empty string if the payload is nil or the value isn't set.
type MultipartForm ¶
type MultipartForm struct { // MaxUploadSize sets the maximum number of bytes used to parse a request body // as multipart/form-data. MaxUploadSize int64 // MaxMemory defines the maximum number of bytes used to parse a request body // as multipart/form-data in memory, with the remainder stored on disk in // temporary files. MaxMemory int64 }
MultipartForm the Multipart request spec https://github.com/jaydenseric/graphql-multipart-request-spec
func (MultipartForm) Do ¶
func (f MultipartForm) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor)
type Options ¶
type Options struct { // AllowedMethods is a list of allowed HTTP methods. AllowedMethods []string }
Options responds to http OPTIONS and HEAD requests
func (Options) Do ¶
func (o Options) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor)
type POST ¶
type POST struct{}
POST implements the POST side of the default HTTP transport defined in https://github.com/APIs-guru/graphql-over-http#post
func (POST) Do ¶
func (h POST) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor)
type Websocket ¶
type Websocket struct { Upgrader websocket.Upgrader InitFunc WebsocketInitFunc InitTimeout time.Duration ErrorFunc WebsocketErrorFunc KeepAlivePingInterval time.Duration PingPongInterval time.Duration // contains filtered or unexported fields }
func (Websocket) Do ¶
func (t Websocket) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor)
type WebsocketError ¶ added in v0.17.6
type WebsocketError struct { Err error // IsReadError flags whether the error occurred on read or write to the websocket IsReadError bool }
func (WebsocketError) Error ¶ added in v0.17.6
func (e WebsocketError) Error() string