handlers

package
v0.10.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateQuery added in v0.10.15

func CreateQuery(c Config, r *http.Request) (string, string, error)

CreateQuery from handler config and request

func NewWebhookHandler added in v0.9.13

func NewWebhookHandler(c Config, gqlHandler http.Handler) http.Handler

func RecoveryHandler

func RecoveryHandler(next http.Handler, logger ErrorLog) http.Handler

RecoveryHandler recovers from panics to return Internal Server Error http response

func WithProtocolInContext

func WithProtocolInContext(next http.Handler) http.Handler

WithProtocolInContext appends request headers to context object

Types

type Config

type Config struct {
	RouterConfig router.Config
	Schema       *graphql.Schema
	Pretty       bool
	GraphiQL     bool
	RootObjectFn handler.RootObjectFn
	CheckOrigin  func(req *http.Request) bool
}

Config new handler

type ErrorLog

type ErrorLog interface {
	Errorf(string, ...interface{})
}

ErrorLog used by recovery handler

type Handler

type Handler struct {
	Schema *graphql.Schema
	// contains filtered or unexported fields
}

Handler implements http.Handler for GraphQL

func New

func New(cfg Config) *Handler

New returns new handler

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler

type ResultCallbackFn

type ResultCallbackFn func(ctx context.Context, params *graphql.Params, result *graphql.Result, responseBody []byte)

ResultCallbackFn called with result

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL