Skip to content
Martin's HTTP package
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ctxkey
tpl
zmail
.codecov.yaml
.travis.yml
LICENSE
README.markdown
auth.go
decode.go
decode_test.go
flash.go
flash_test.go
go.mod
go.sum
handlers.go
headers.go
headers_test.go
ratelimit.go
ratelimit_test.go
reqlog.go
route.go
secret.go
serve.go
static.go
tpl.go
tplfunc.go
tplfunc_test.go
unpanic.go
util.go
util_test.go
wrap.go
wrap_test.go

README.markdown

This project is considered experimental Build Status codecov GoDoc

Martin's HTTP package: It's not a "framework", but just a collection of functions for building HTTP services.

Convention over configuration. Honestly, I'm not sure how useful this will be for other people at this stage (or ever), but it's pretty useful for me.


zhttp.Wrap() allows returning errors from HTTP endpoints:

http.HandleFunc("/bar", zhttp.Wrap(func(w http.ResponseWriter, r *http.Request) error {
  d, err := getData()
  if err != nil {
      return err
  }

  return zhttp.String("Hello, %s", d)
}))

It's just more convenient than http.Error(...) followed by a return. The ErrFunc() will be used to report returned errors (you can override it if you need to).

Return helpers:

  • zhttp.String()
  • zhttp.JSON()
  • zhttp.Template()
  • zhttp.SeeOther()

zhttp.Decode()scans forms, JSON body, or URL query parameters in to a struct. It's just a convencience wrapper around formam.


zhttp.HostRoute() routes request to chi routers based on the Host header.

You can’t perform that action at this time.