Documentation ¶
Index ¶
- func EchoContext(ctx context.Context, c echo.Context) context.Context
- func EchoForContext(ctx context.Context) echo.Context
- func Middleware(server *Server) echo.MiddlewareFunc
- func ServerContext(ctx context.Context, server *Server) context.Context
- type Context
- type GraphQL
- type MiddlewareConfig
- type Server
- func (s *Server) AddFuncs(funcs template.FuncMap)
- func (s *Server) AddStaticFunc(fs ...validate.StaticFunc)
- func (s *Server) AddStaticVar(key string, value any) error
- func (s *Server) AppInfo() string
- func (s *Server) CSRFAddSkip(routes ...string)
- func (s *Server) DefaultMiddlewareWithConfig(conf *MiddlewareConfig) *Server
- func (s *Server) Echo() *echo.Echo
- func (s *Server) GetSessionManager() *scs.SessionManager
- func (s *Server) HTTPErrorHandler(err error, c echo.Context)
- func (s *Server) Initialize() *Server
- func (s *Server) LoadTemplates(paths ...string) error
- func (s *Server) LoadTemplatesFS(tfs fs.FS, paths ...string) error
- func (s *Server) LogErrorFunc(c echo.Context, err error, stack []byte) error
- func (s *Server) Logger() echo.Logger
- func (s *Server) QueueTask(qname string, task *work.Task) error
- func (s *Server) Run()
- func (s *Server) SetQueueTimeout(d time.Duration)
- func (s *Server) Shutdown()
- func (s *Server) WithAppInfo(name, version string) *Server
- func (s *Server) WithCertManager(cm *autocert.Manager) *Server
- func (s *Server) WithDefaultMiddleware() *Server
- func (s *Server) WithEmail(svc *email.ServiceQueue) *Server
- func (s *Server) WithMiddleware(middlewares ...echo.MiddlewareFunc) *Server
- func (s *Server) WithQueues(queues ...*work.Queue) *Server
- func (s *Server) WithSchema(schema graphql.ExecutableSchema, scopes []string) *Server
- func (s *Server) WithStorage(svc storage.Service) *Server
- func (s *Server) WorkQueues() []*work.Queue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EchoContext ¶
EchoContext adds the current requests echo.Context instance to the request context.Context. This is a total hack to get around the current gobwebs design of using server.Context.User (maybe should rethink this design all together)
func EchoForContext ¶
EchoForContext pulls echo.Context value for context
Types ¶
type Context ¶
Context is the context passed to handlers and middlewares
func (*Context) Error ¶
Error is needed because otherwise it will send an instance of *echo.context, and we want the user info, etc. from the gobwebs Context struct
func (*Context) Render ¶
Render is a wrapper for the echo.Context.Render method. The purpose of this is to provide *server.Context to dynamic template functions. To use this, you need to type assert to *server.Context in your handler and call the render directly on the resulting context, not on the echo.Context
type GraphQL ¶
type GraphQL struct { Schema graphql.ExecutableSchema MaxComplexity int MaxUploadSize int }
GraphQL is a holder for a graphql schema and options
type MiddlewareConfig ¶
type MiddlewareConfig struct { Sessions bool // GetSessionManager should be used to customize the values of the // scs.SessionManager instance. A function was chosen because of the // various options it supports. This makes it easier for others to // integrate their specific needs versus a large type with a ton of // flags that we would have to parse through. GetSessionManager func(srv *Server) *scs.SessionManager // If true then the session expirey date (note, this is NOT the cookie // expiry date) is extended by the default session lifetime amount from // time.Now() SessionTimeout bool ServerContext bool }
MiddlewareConfig is a config struct to set default middlewares
type Server ¶
type Server struct { Config *config.Config DB *sql.DB Session *scs.SessionManager Email *email.ServiceQueue Storage storage.Service GQL *GraphQL // contains filtered or unexported fields }
Server is the global echo application server
func ForContext ¶
ForContext pulls user value for context
func New ¶
New creates a new server instance
func (*Server) AddFuncs ¶
AddFuncs functions to the global template function map
func (*Server) AddStaticFunc ¶
func (s *Server) AddStaticFunc(fs ...validate.StaticFunc)
AddStaticFunc adds a static function to the template renderer context
func (*Server) AddStaticVar ¶
AddStaticVar adds a static variable to the template renderer context
func (*Server) AppInfo ¶
AppInfo returns a string in format: `<name> <version>`
func (*Server) CSRFAddSkip ¶
CSRFAddSkip adds a route that is allowed to skip CSRF protection
func (*Server) DefaultMiddlewareWithConfig ¶
func (s *Server) DefaultMiddlewareWithConfig(conf *MiddlewareConfig) *Server
DefaultMiddlewareWithConfig sets default middleware for the application
func (*Server) Echo ¶
func (s *Server) Echo() *echo.Echo
Echo returns the servers *echo.Echo instance
func (*Server) GetSessionManager ¶
func (s *Server) GetSessionManager() *scs.SessionManager
GetSessionManager returns the default configured session. To customize this session please see `MiddlewareConfig.GetSessionManager`
func (*Server) HTTPErrorHandler ¶
HTTPErrorHandler custom error handler for entire app
func (*Server) Initialize ¶
Initialize loads the echo environments
func (*Server) LoadTemplates ¶
LoadTemplates will add to the existing template mapping
func (*Server) LoadTemplatesFS ¶
LoadTemplatesFS will add to the existing template mapping
func (*Server) LogErrorFunc ¶
LogErrorFunc will handle logging the stack trace for an error
func (*Server) QueueTask ¶
QueueTask will add a task to a specific queue. Queue should be identified by queue name.
func (*Server) SetQueueTimeout ¶
SetQueueTimeout will set the timeout duration to use when waiting for queues to shutdown
func (*Server) Shutdown ¶
func (s *Server) Shutdown()
Shutdown will close echo server and work queues
func (*Server) WithAppInfo ¶
WithAppInfo sets the application name and version
func (*Server) WithCertManager ¶
WithCertManager adds an autocert.Manager to be used for auto TLS
func (*Server) WithDefaultMiddleware ¶
WithDefaultMiddleware sets default middleware for the application
func (*Server) WithEmail ¶
func (s *Server) WithEmail(svc *email.ServiceQueue) *Server
WithEmail sets the email ServiceQueue instance
func (*Server) WithMiddleware ¶
WithMiddleware add user-defined middleware to the server
func (*Server) WithQueues ¶
WithQueues add dowork task queues for this server to manage
func (*Server) WithSchema ¶
func (s *Server) WithSchema( schema graphql.ExecutableSchema, scopes []string) *Server
WithSchema 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.
func (*Server) WithStorage ¶
WithStorage sets the email ServiceQueue instance