server

package
v0.0.0-...-bd40a71 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: BSD-3-Clause Imports: 35 Imported by: 33

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Access

func Access(ctx context.Context, obj interface{}, next graphql.Resolver,
	scope string, kind string) (interface{}, error)

func AnonInternal

func AnonInternal(ctx context.Context, obj interface{},
	next graphql.Resolver) (interface{}, error)

func EmailRecover

func EmailRecover(ctx context.Context, _origErr interface{}) error

Provides a graphql.RecoverFunc which will print the stack trace, and if debug mode is not enabled, email it to the administrator.

func Internal

func Internal(ctx context.Context, obj interface{},
	next graphql.Resolver) (interface{}, error)

func Private

func Private(ctx context.Context, obj interface{},
	next graphql.Resolver) (interface{}, error)

func RemoteAddr

func RemoteAddr(ctx context.Context) string

RemoteAddr returns the remote address for this context. It is guaranteed to be valid input for `net.ParseIP()`.

Types

type Server

type Server struct {
	Schema graphql.ExecutableSchema

	MaxComplexity int
	// contains filtered or unexported fields
}

func ForContext

func ForContext(ctx context.Context) *Server

func NewServer

func NewServer(service string, conf ini.File) *Server

Creates a new common server context for a SourceHut GraphQL daemon.

func (*Server) Router

func (server *Server) Router() chi.Router

Returns the chi Router being used for this sever.

func (*Server) Run

func (server *Server) Run()

Run the server. Blocks until SIGINT is received.

func (*Server) WithDefaultMiddleware

func (server *Server) WithDefaultMiddleware() *Server

Adds the default middleware to this server, including:

- Configuration middleware - PostgresSQL connection pool - Redis connection - Authentication middleware - An email queue - Standard rigging: logging, x-real-ip, instrumentation, etc

func (*Server) WithMiddleware

func (server *Server) WithMiddleware(
	middlewares ...func(http.Handler) http.Handler) *Server

Add user-defined middleware to the server

func (*Server) WithQueues

func (server *Server) WithQueues(queues ...*work.Queue) *Server

Add dowork task queues for this server to manage

func (*Server) WithSchema

func (server *Server) WithSchema(
	schema graphql.ExecutableSchema, scopes []string) *Server

Adds a GraphQL schema for this server. The second parameter shall be the list of scopes, as strings, which are supported by this schema. This function configures routes for the router; all middlewares must be configured before this is called.

Jump to

Keyboard shortcuts

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