router

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadTemplates added in v0.3.8

func LoadTemplates(engine *gin.Engine) error

LoadTemplates loads templates found at `web-template-base-dir` into the Gin engine, or errors if templates cannot be loaded.

The special functions "include" and "includeAttr" will be added to the template funcMap for use in any template. Use these "include" functions when you need to pass a template through a pipeline. Otherwise, prefer the built-in "template" function.

Types

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router provides the HTTP REST interface for GoToSocial, using gin.

func New

func New(ctx context.Context) (*Router, error)

New returns a new Router, which wraps an http server and gin handler engine.

The router's Attach functions should be used *before* the router is Started.

When the router's work is finished, Stop should be called on it to close connections gracefully.

The provided context will be used as the base context for all requests passing through the underlying http.Server, so this should be a long-running context.

func (*Router) AttachGlobalMiddleware added in v0.7.0

func (r *Router) AttachGlobalMiddleware(handlers ...gin.HandlerFunc) gin.IRoutes

func (*Router) AttachGroup added in v0.3.8

func (r *Router) AttachGroup(relativePath string, handlers ...gin.HandlerFunc) *gin.RouterGroup

func (*Router) AttachHandler

func (r *Router) AttachHandler(method string, path string, handler gin.HandlerFunc)

func (*Router) AttachNoRouteHandler

func (r *Router) AttachNoRouteHandler(handler gin.HandlerFunc)

func (*Router) Start

func (r *Router) Start() error

Start starts the router nicely.

It will serve two handlers if letsencrypt is enabled, and only the web/API handler if letsencrypt is not enabled.

func (*Router) Stop

func (r *Router) Stop() error

Stop shuts down the router nicely.

Jump to

Keyboard shortcuts

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