aldas on master
Timeout mw: rework how test wai… (compare)
next(c)
returns.
e.GET("/", func(c echo.Context) error {
c.Response().Writer.Write([]byte("hello"))
time.Sleep(5 * time.Second)
return nil
})
e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
// gather stats before
err := next(c)
// gather telemetry after
go func() {
time.Sleep(1 * time.Second) // do work, and report without affecting client
fmt.Println("reporting telemetry")
}()
return err
}
})
something like that
c.Set()
. This is standard way to pass information from middleware to middleware and to handler. Ala JWT uses it store token in request context https://github.com/labstack/echo/blob/7f502b1ff10913aeab28abab64f2bf45952c768d/middleware/jwt.go#L234
Re: https://echo.labstack.com/middleware/rate-limiter/
How do I use this? I want a basic rate limiter and hence using the following:
e.Use(middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(4)))
ON compilation:
./ari.go:55:8: undefined: middleware.RateLimiter
./ari.go:55:31: undefined: middleware.NewRateLimiterMemoryStore
e := echo.New()
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Content-Length
header?
%q
so the single slash is escaped there. And then when echo prints the message the same thing happens and each slash is escaped again, making a single slash into four. Does anyone have an idea on how to deal with this?
\t
makes those characters appear directly in the response instead of being processed, so I'm guessing something happens there and an escaped backslash \\
in the string is returned as-is
see https://pkg.go.dev/encoding/json#Marshal
Array and slice values encode as JSON arrays, except that []byte encodes as a base64-encoded string, and a nil slice encodes as the null JSON value.