Clean up some code

This commit is contained in:
Nise Void 2019-07-03 12:24:45 +02:00
parent 60f82143da
commit 317961ab6e
Signed by: NiseVoid
GPG Key ID: FBA14AC83EA602F3
1 changed files with 3 additions and 2 deletions

View File

@ -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)
}