mirror of
https://github.com/eolinker/apinto
synced 2025-10-05 00:42:47 +08:00
retry 和 timeout存在httpHandler,并使用ctx传
This commit is contained in:
@@ -2,6 +2,7 @@ package http_router
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
http_service "github.com/eolinker/apinto/node/http-context"
|
||||
|
||||
@@ -26,10 +27,12 @@ type httpHandler struct {
|
||||
filters eocontext.IChainPro
|
||||
disable bool
|
||||
websocket bool
|
||||
|
||||
retry int
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
func (h *httpHandler) ServeHTTP(ctx eocontext.EoContext) {
|
||||
|
||||
httpContext, err := http_context.Assert(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -50,6 +53,9 @@ func (h *httpHandler) ServeHTTP(ctx eocontext.EoContext) {
|
||||
}
|
||||
ctx = wsCtx
|
||||
}
|
||||
//set retry timeout
|
||||
ctx.WithValue(http_complete.KeyHttpRetry, h.retry)
|
||||
ctx.WithValue(http_complete.KeyHttpTimeout, h.timeout)
|
||||
|
||||
//Set Label
|
||||
ctx.SetLabel("api", h.routerName)
|
||||
|
Reference in New Issue
Block a user