router

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gate

func Gate(db *sqlx.DB) web.Gate

Gate returns a web.Gate that checks if the current authenticated User has the access permissions to the current Namespace, or if they are a Collaborator in that Namespace. If the current User can access the current Namespace, then it is set in the request's context.

Types

type Router

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

Router is what registers the UI and API routes for managing namespaces. It implements the server.Router interface.

func New

func New(cfg *config.Server, h web.Handler, mw web.Middleware) *Router

func (*Router) RegisterAPI

func (r *Router) RegisterAPI(prefix string, mux *mux.Router, gates ...web.Gate)

RegisterAPI registers the API routes for working with namespaces. The given prefix string is used to specify where the API is being served under. This applies all of the given gates to all routes registered. These routes response with a "application/json" Content-Type.

func (*Router) RegisterUI

func (r *Router) RegisterUI(mux *mux.Router, csrf func(http.Handler) http.Handler, gates ...web.Gate)

RegisterUI registers the UI routes for Namespace creation, and management. There are two types of routes, simple auth routes, and individual namespace routes. These routes respond with a text/html Content-Type.

simple auth routes - These routes (/namespaces, /namespaces/create, /invites, /invites/{invite:[0-9]+}) havbe the auth middleware applied to them to check if a user is authenticated to access the route. The given http.Handler is applied to these routes for CSRF protection.

individual namespace routes - These routes (prefixed with /n/{username}/{namespace:[a-zA-Z0-9\\/?]+}), use the given http.Handler for CSRF protection, and the given gates for auth checks, and permission checks.

Jump to

Keyboard shortcuts

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