https://github.com/joho/prohttphandler
A (not very) pro http handler for go (does simple asset serving and exact match paths -> handler funcs)
https://github.com/joho/prohttphandler
Last synced: about 1 year ago
JSON representation
A (not very) pro http handler for go (does simple asset serving and exact match paths -> handler funcs)
- Host: GitHub
- URL: https://github.com/joho/prohttphandler
- Owner: joho
- License: mit
- Created: 2013-09-18T01:28:35.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-12-22T23:37:23.000Z (over 8 years ago)
- Last Synced: 2025-01-26T02:52:16.490Z (over 1 year ago)
- Language: Go
- Size: 3.91 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ProHttpHandler
A teeny tiny http handler for Go that I wanted to reuse across a couple of projects.
It gives you two things: static asset handling (in a path of your choice) and exact matching of paths to http handler funcs
## Example
An example that serves all files in "public" at / and serves up a super boring homepage on port 8080.
```go
package main
import (
"fmt"
"github.com/joho/prohttphandler"
"log"
"net/http"
)
func main() {
handler := prohttphandler.New("public")
handler.ExactMatchFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "This is the homepage at /")
})
log.Fatal(http.ListenAndServe(":8080", handler))
}
```
There are some very poor [docs here](http://godoc.org/github.com/joho/prohttphandler)
---
Copyright 2013 [John Barton](https://johnbarton.co/) (but under MIT Licence)