Documentation ¶
Index ¶
- func AddIndexRoute(r Route)
- func AddRoute(rt Route)
- func AddSubroute(namespace string, rts []Route)
- func AppHome() string
- func Auth(next http.Handler) http.Handler
- func EnableDebugMode(enable bool)
- func GetRouter() http.Handler
- func HandleForbidden(w http.ResponseWriter, r *http.Request)
- func Log(next http.Handler) http.Handler
- func LoginRequired(next http.Handler) http.Handler
- func RenderError(w http.ResponseWriter, err errors.HttpError)
- func RenderPage(w http.ResponseWriter, url string) error
- func RenderTemplate(w http.ResponseWriter, contentTemplate string, data interface{}) error
- func ServeFile(w http.ResponseWriter, r *http.Request)
- func SetAppHome(dir string)
- func SetStaticDir(dir string)
- type Route
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddIndexRoute ¶
func AddIndexRoute(r Route)
AddIndexRoute ensures that the general path is added last for matching order
func AddRoute ¶
func AddRoute(rt Route)
AddRoute registers a new route to the main router. Routes should register themselves on init.
func AddSubroute ¶
AddSubroute adds a subroute with the given namespace and paths to handle to the main router. Subroutes should be added on init.
func Auth ¶
Auth ensures that the requester is authenticated and authorized to access the resource. Failures are logged as well.
func EnableDebugMode ¶
func EnableDebugMode(enable bool)
EnableDebugMode allows for detailed output and full error messages to be sent to clients. NOTE: do not use in production!
func HandleForbidden ¶
func HandleForbidden(w http.ResponseWriter, r *http.Request)
HandleForbidden serves a HTTP 403 Forbidden page to the user, denying access to the resource
func Log ¶
Log records the resource requested and the origin of the request. All routes should call Log (directly or indirectly)
func LoginRequired ¶
LoginRequired is a shortcut to call both Log and Auth middlewares.
func RenderError ¶
func RenderError(w http.ResponseWriter, err errors.HttpError)
RenderError writes out user errors and genericized server errors to the client
func RenderPage ¶
func RenderPage(w http.ResponseWriter, url string) error
RenderPage writes the page contents to the response body
func RenderTemplate ¶
func RenderTemplate(w http.ResponseWriter, contentTemplate string, data interface{}) error
RenderTemplate executes the given template body
func ServeFile ¶
func ServeFile(w http.ResponseWriter, r *http.Request)
ServeFile writes the requested file to the response
func SetStaticDir ¶
func SetStaticDir(dir string)
SetStaticDir adds a file server to handle static files in the specified directory