Skip to content

Instantly share code, notes, and snippets.

@MacoTasu
Created June 24, 2015 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MacoTasu/746d42c6cced111508b2 to your computer and use it in GitHub Desktop.
Save MacoTasu/746d42c6cced111508b2 to your computer and use it in GitHub Desktop.
ダンゲル氏の傑作コード
func (k *Ksatriya) handle(method, path string, hf HandlerFunc, filterFuncs map[string]FilterFunc) {
k.router.Handle(method, path, func(w http.ResponseWriter, req *http.Request, args httprouter.Params) {
ctx := NewContext(req, args)
if ff, ok := filterFuncs[BeforeFilterFuncKey]; ok {
ff(ctx)
if ctx.Response().StatusCode() == http.StatusFound {
ctx.Write(w)
return
}
}
hf(ctx)
if ctx.Response().StatusCode() == http.StatusFound {
ctx.Write(w)
return
}
if ff, ok := filterFuncs[AfterFilterFuncKey]; ok {
ff(ctx)
}
ctx.Write(w)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment