router
v1.1.1
Documentation
pkg.go.dev ↗Functions
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 Key. If the current user can access the current key then it is set in the request's context.
Types
Router
type Router struct {
// contains filtered or unexported fields
}
Router is what registers the UI and API routes for managing SSH keys. It implements the server.Router interface.
New
func New(cfg *config.Server, h web.Handler, mw web.Middleware) *Router
Router.RegisterAPI
func (r *Router) RegisterAPI(prefix string, mux *mux.Router, gates ...web.Gate)
RegisterAPI registers the API routes for working with keys. 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.
Router.RegisterUI
func (r *Router) RegisterUI(mux *mux.Router, csrf func(http.Handler) http.Handler, gates ...web.Gate)
RegisterUI registers the UI routes for working with keys There are two types of route groups, simple auth routes, and individual key routes. These routes respond with a "text/html" Content-Type.
simple auth routes - These routes are registered under the "/keys" prefix of the given router. The Auth middleware is applied to all registered routes. CSRF protection is applied to all the registered routes.
individual key routes - These routes are registered under the "/keys/{key:[0-9]}" prefix of the given router. Each given gate is applied to the registered routes, along with the given CSRF protection.