retry 和 timeout存在httpHandler,并使用ctx传

This commit is contained in:
chenjiekun
2023-03-02 16:35:52 +08:00
parent 44678168a4
commit bb7d82daca
3 changed files with 32 additions and 8 deletions

View File

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