Created
June 24, 2015 07:42
-
-
Save MacoTasu/746d42c6cced111508b2 to your computer and use it in GitHub Desktop.
ダンゲル氏の傑作コード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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