router

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadTemplateFunctions added in v0.2.0

func LoadTemplateFunctions(engine *gin.Engine)

func LoadTemplates added in v0.3.8

func LoadTemplates(engine *gin.Engine) error

LoadTemplates loads html templates for use by the given engine

Types

type Router

type Router interface {
	// Attach global gin middlewares to this router.
	AttachGlobalMiddleware(handlers ...gin.HandlerFunc) gin.IRoutes
	// AttachGroup attaches the given handlers into a group with the given relativePath as
	// base path for that group. It then returns the *gin.RouterGroup so that the caller
	// can add any extra middlewares etc specific to that group, as desired.
	AttachGroup(relativePath string, handlers ...gin.HandlerFunc) *gin.RouterGroup
	// Attach a single gin handler to the router with the given method and path.
	// To make middleware management easier, AttachGroup should be preferred where possible.
	// However, this function can be used for attaching single handlers that only require
	// global middlewares.
	AttachHandler(method string, path string, handler gin.HandlerFunc)

	// Attach 404 NoRoute handler
	AttachNoRouteHandler(handler gin.HandlerFunc)
	// Start the router
	Start()
	// Stop the router
	Stop(ctx context.Context) error
}

Router provides the REST interface for gotosocial, using gin.

func New

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

New returns a new Router.

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.

Jump to

Keyboard shortcuts

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