Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DynamicRouter ¶
type DynamicRouter struct {
// contains filtered or unexported fields
}
DynamicRouter is a simple http router
Implements the http/Handler interface
func NewDynamicRouter ¶
func NewDynamicRouter() *DynamicRouter
NewDynamicRouter create a new DynamicRouter
func (*DynamicRouter) HandleFunc ¶
func (r *DynamicRouter) HandleFunc(pattern string, handler Handler, filters ...HttpFilter)
HandleFunc register a new Handler for a given pattern
func (*DynamicRouter) ServeHTTP ¶
func (r *DynamicRouter) ServeHTTP(res http.ResponseWriter, req *http.Request)
http/Handler implementation
func (*DynamicRouter) ServeStaticAt ¶
func (r *DynamicRouter) ServeStaticAt(root string, mode FileServerMode)
type FileServerMode ¶
type FileServerMode string
FileServerMode allow to adapt some behavior of the file server.
const ( // classic mode handle all requests considering that there is no routing in front end code. // it behave like "classic" web app. When a resource is not found => 404 Classic FileServerMode = "classic" // spa mode considers that all the routing is done in the browser. Some files other than index.html // may be loaded, but if a request does not fit a file, the request is changed to serve `/` instead. Spa FileServerMode = "spa" )
type Handler ¶
function type used by application code
func WrapHttpHandleFunc ¶
func WrapHttpHandleFunc(f func(w http.ResponseWriter, r *http.Request)) Handler
WrapHttpHandleFunc make easier to integrate route with existing code by transforming a standart httpHandleFunc into a route.Handler
type HttpFilter ¶
type HttpFilter func(http.ResponseWriter, *http.Request) bool
functions that are executed before there corresponding handler. if an error is returned, the pipe execution is stopped. The filter MUST take care of status and body response.
Click to show internal directories.
Click to hide internal directories.