Documentation
¶
Overview ¶
A totally pro http handler. One that isn't particularly pro at all, it was just handy and I needed it in multiple projects.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ProHttpHandler ¶
type ProHttpHandler struct {
// contains filtered or unexported fields
}
The actuall http handler
func New ¶
func New(publicStaticAssetPath string) (h *ProHttpHandler)
Create a ProHttpHandler You need to give it a path to use as the static assets root
func (*ProHttpHandler) ExactMatchFunc ¶
func (h *ProHttpHandler) ExactMatchFunc(path string, handlerFunc func(http.ResponseWriter, *http.Request))
Registers a http handler func for the path you specify
func (*ProHttpHandler) ServeHTTP ¶
func (h *ProHttpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP will do one of three things:
- It will check if there is a handler func registered for the *exact* path of the request
- If there is no exact match, it will try and find a file in the static asset path to serve (no dir listings though)
- If neither of the above, it will 404 in an ugly way
If the client sends an Accept-Encoding of gzip, then they'll get it gzipped. Keep an eye out for weird Content-Type issues if you're gzipping, as this will try and auto-guess the content type and may not be 100% accurate.
Click to show internal directories.
Click to hide internal directories.