forked from Fuyu/router
Clean up some code
This commit is contained in:
parent
60f82143da
commit
317961ab6e
@ -102,6 +102,7 @@ func (r *Router) Start(addr string) error {
|
||||
return r.server.ListenAndServe()
|
||||
}
|
||||
|
||||
// StartTLS starts a TLS web server using the given key, cert and config and binds to the given address
|
||||
func (r *Router) StartTLS(addr, certFile, keyFile string, conf *tls.Config) error {
|
||||
httpr := r.getHttpr()
|
||||
|
||||
@ -115,7 +116,7 @@ func (r *Router) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(time.Second*5))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
err := r.server.Shutdown(ctx)
|
||||
if err == context.DeadlineExceeded {
|
||||
@ -211,7 +212,7 @@ func handleReq(r *Router, handle Handle, m []Middleware) httprouter.Handle {
|
||||
c := newContext(r, res, req, param)
|
||||
|
||||
f := handle
|
||||
for i := len(m) - 1; i >= 0; i-- { // TODO: 1,2,3 of 3,2,1
|
||||
for i := len(m) - 1; i >= 0; i-- {
|
||||
f = m[i](f)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user