https://github.com/gbrlsnchs/httphandler
Golang minimalist HTTP handler
https://github.com/gbrlsnchs/httphandler
go golang http-handler
Last synced: 9 days ago
JSON representation
Golang minimalist HTTP handler
- Host: GitHub
- URL: https://github.com/gbrlsnchs/httphandler
- Owner: gbrlsnchs
- License: mit
- Created: 2017-09-21T23:03:28.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-02T18:39:41.000Z (about 7 years ago)
- Last Synced: 2025-02-07T13:54:06.440Z (3 months ago)
- Topics: go, golang, http-handler
- Language: Go
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# httphandler (Minimalist HTTP Handler)
[](https://travis-ci.org/gbrlsnchs/httphandler)
[](https://godoc.org/github.com/gbrlsnchs/httphandler)## About
This package is a minimalist HTTP handler for [Go] (or Golang) HTTP servers.
It is compatible with any response content type that has a marshaller function.## Usage
Full documentation [here].## Example
```go
package httphandler_testimport (
"errors"
"net/http""github.com/gbrlsnchs/httphandler"
)func Example() {
h := httphandler.New(func(w http.ResponseWriter, _ *http.Request) (httphandler.Responder, error) {
err := errors.New("Example error")if err != nil {
return nil, &errorMockup{
Msg: err.Error(),
Code: http.StatusBadRequest,
}
}return &responderMockup{
msg: "Hello, World!",
code: http.StatusOK,
}, nil
})http.Handle("/example", h)
}
```## Contribution
### How to help:
- Pull Requests
- Issues
- Opinions[Go]: https://golang.org
[here]: https://godoc.org/github.com/gbrlsnchs/httphandler