Skip to content

Commit

Permalink
feat: reply with cache-control: 0 for browser-facing APIs
Browse files Browse the repository at this point in the history
Closes #360
  • Loading branch information
aeneasr committed Jul 27, 2020
1 parent 54dcc4d commit 1a45b53
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions x/router.go
Expand Up @@ -21,3 +21,33 @@ func NewRouterAdmin() *RouterAdmin {
Router: httprouter.New(),
}
}

// GET is a shortcut for router.Handle("GET", path, handle)
func (r *RouterPublic) GET(path string, handle httprouter.Handle) {
r.Handle("GET", path, NoCacheHandler(handle))
}

// HEAD is a shortcut for router.Handle("HEAD", path, handle)
func (r *RouterPublic) HEAD(path string, handle httprouter.Handle) {
r.Handle("HEAD", path, NoCacheHandler(handle))
}

// POST is a shortcut for router.Handle("POST", path, handle)
func (r *RouterPublic) POST(path string, handle httprouter.Handle) {
r.Handle("POST", path, NoCacheHandler(handle))
}

// PUT is a shortcut for router.Handle("PUT", path, handle)
func (r *RouterPublic) PUT(path string, handle httprouter.Handle) {
r.Handle("PUT", path, NoCacheHandler(handle))
}

// PATCH is a shortcut for router.Handle("PATCH", path, handle)
func (r *RouterPublic) PATCH(path string, handle httprouter.Handle) {
r.Handle("PATCH", path, NoCacheHandler(handle))
}

// DELETE is a shortcut for router.Handle("DELETE", path, handle)
func (r *RouterPublic) DELETE(path string, handle httprouter.Handle) {
r.Handle("DELETE", path, NoCacheHandler(handle))
}

0 comments on commit 1a45b53

Please sign in to comment.