Documentation ¶
Index ¶
- func LoadTemplates(engine *gin.Engine) error
- type Router
- func (r *Router) AttachGlobalMiddleware(handlers ...gin.HandlerFunc) gin.IRoutes
- func (r *Router) AttachGroup(relativePath string, handlers ...gin.HandlerFunc) *gin.RouterGroup
- func (r *Router) AttachHandler(method string, path string, handler gin.HandlerFunc)
- func (r *Router) AttachNoRouteHandler(handler gin.HandlerFunc)
- func (r *Router) Start() error
- func (r *Router) Stop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadTemplates ¶ added in v0.3.8
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 ¶
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)