Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
Patrick Steadman
thanks for the guidance!
Has anyone experience with setting up a sse (server-side events) endpoint in echo?
My endpoint always gets closed after write timeout and is not kept alive :(
Kehinde Ogunde
type Day struct {
  Breakfast string  `breakfast: "json"`
  Lunch string      `lunch: "json"`
  Dinner string     `dinner: "json"`

func (h *Handler) CreateDay(c echo.Context) error {
  body := new(Day)
  if err := c.Bind(body); err != nil {
    return c.JSON(http.StatusBadRequest, err)
  c.JSON(http.StatusCreated, body)

jsonDay := `{"breakfast": "Rice and Egg", "lunch": "Amala and Soup", "dinner": "Plantain and Egg"}`

func TestCreateDay(t *testing.T) {
  e := echo.New()
  req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(jsonDay))
  req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
  rec := httptest.NewRecorder()
  c := e.NewContext(req, rec)
  h := &Handler{roaster}

  if assert.NoError(t, h.CreateDay(c)) {
    assert.Equal(t, http.StatusCreated, rec.Code)
    assert.Equal(t, jsonDay, rec.Body.String()) //ERROR

Error:          Not equal:
expected: "{\"breakfast\": \"Rice and Egg\", \"lunch\": \"Amala and Soup\", \"dinner\": \"Plantain and Egg\"}"
actual  : "{\"Breakfast\":\"Rice and Egg\",\"Lunch\":\"Amala and Soup\",\"Dinner\":\"Plantain and Egg\"}\n"

Is there something I'm doing wrong?
@coach-K json:"breakfast" not breakfast:"json" ;)
Jose Then
Does anyone have recommendations in using echo with a jamstack ?
Siddharth Prakash Singh
Is there an easy way to insert request id generated from RequestId middleware as one of the default logger header?
does anyone know of server code generator from open api spec 2.0 for echo golang framework. the one i know generates for spec 3.0 and doesnt do nested models. https://github.com/deepmap/oapi-codegen
Jonathan Curran
Hah speaking of openapi; is there a openapi doc generator? i.e. build docs based on the server and models?
Kwanghoo Park
Is there any ways to check if c.QueryParam() is empty or not other than using if clauses?
Martti T.
@jerry901 if you want to get multiple query param only if params exist (or use custom default values) you might want to check echo.QueryParamsBinder(c) https://echo.labstack.com/guide/binding/ (scroll down, there is an example).
Hello. I wonder if the built-in Let's Encrypt support also includes the automatic renewal. Is echo automatically renewing the certificate? In which interval? I found no information on their documentation pages. Or do I have to trigger that on my own? How?
Martti T.
Docs for auto cert functionality that echo.StartAutoTLS uses can be found here https://pkg.go.dev/golang.org/x/crypto/acme/autocert
    // RenewBefore optionally specifies how early certificates should
    // be renewed before they expire.
    // If zero, they're renewed 30 days before expiration.
    RenewBefore time.Duration
@aldas Thanks! That was exactly I was looking for. Great :-)
Manolis Stamatogiannakis
Hi all. I've been playing with echo routing, and I noticed that the presence of unescaped parentheses prevent unescaping any other escaped characters.
Example with dummy echo service:
# escaped ()
$ wget -O - 'http://localhost:8000/noble%20developer%20%28echo%29' 2>/dev/null
Hello, noble developer (echo)!
# unescaped ()
$ wget -O - 'http://localhost:8000/noble%20developer%20(echo)' 2>/dev/null  ✹ ✭
Hello, noble%20developer%20(echo)!
Manolis Stamatogiannakis
Is there some reason for this behaviour? I'd expect both cases to have the same output.
Dmitrii Okunev (at work)
For me it kind of makes sense: when you add parentheses you show the parser that the URL is not escaped.
But I'm not the developer of echo :)
Manolis Stamatogiannakis
Yes, that was my guess for explaining what is happening. Still, the decoding of path components should follow some RFC document.
Also, url.PathUnescape() decodes the two cases to the same string: https://play.golang.org/p/4Caj1hFjdWd
Which makes Echo's behaviour puzzling.

Hi all.
I really appreciate the echo framework, and currently I am trying to use the RateLimiter-Middleware. However when I spedify a RateLimit between 0 and 1 no requests are accepted at all:


Shouldn't a value between 0 and 1 be interpreteded consistently as a valid rate? Why else should floats be allowed then?

Dmitrii Okunev (at work)
I'm not a developer of echo, so I would guess it was a mistake and should've been an integer. It does not make much sense to have fractional limiter. Because it counts natural numbers in a defined time interval.
2 replies
Out of curiosity what rate limit you want to set? 1rps or 1rpm?
Dmitrii Okunev (at work)
But I would've open an issue anyway: to either use integers or to implement support of floats :)
1 reply
Damien Gallagher
Hi. With the logging middleware, is it possible to exclude certain requests from being logged . I am thinking to not log the /health endpoint that is called every 5 seconds from the load balancer
4 replies
Arun Gopalpuri
Or you can use the “Skipper” function.
hello everyone
I have issues download file, somebody help my thanks
Dmitrii Okunev (at work)
Hello. I guess to help it is required to know more information about the issue. What do you do, what do you expect, what do you get instead?
hi there..i'm not able to use redis session with the latest version echo/v4 v4.2.2 is my fault or it's doesn't work at all?
Artur Mustafin

I have issues download file, somebody help my thanks

what the issue?

When use cookie in jwt auth not working , {"message":"missing or malformed jwt"}
SigningKey: []byte(os.Getenv("SECRET_KEY")),
TokenLookup: "cookie:Authorization",
but when in change TokenLookup to header:Authorization it works properly
Dmitrii Okunev (at work)
Most likely unrelated, but be aware: cookie fields has limited size. But to diagnose your case it is not enough information: you need to either publish the code, or to show traffic dumps or something to look at :)
I checked the cookie i stroed is same value as the jwt token
Yassine Rais
Hi guys! Just wondering if there is a simple echo project with a structured websocket application :D environment/testing already configured. i will be grateful if someone suggest me somthing ✨ thanks
Hey all, is it possible to use a single echo.Echo instance to run both HTTP and HTTPS conenctions?
Also, I don't see a way to use StartAutoTLS with a custom http.Server instance, nor with anything else. What's the right way to customise read/write/idle timeouts?
Iván Álvarez
Hi all, maybe someone could help me. I would like to send large files with "chunked" transfer to an Echo backend. When I send a chunked request get following response code=400, message=unknown type, internal=unknown type. Could someone share a starting point to know how to deal with this feature with Echo? I have searched info about this, with no luck :(. Thanks!
Vasiliy Toporov
Hello. Has anyone made an implementation of Echo Logger interface via Zap logger? Could you share an example?
I've found one with middleware https://github.com/brpaz/echozap but it seems to be an integration without interface implementation...
somebody help me. I want get multiple checkbox from request. I'm try a := c.Request().Form["role"] however it's return a null arry 2021/05/14 16:28:37 role []
Evening all, I've been working on my first project w/ the Echo framework and was wondering if anyone has gone down the gRPC support route before?
I have a few scenarios in which I have a desire to stream data like logs back to my clients and was thinking gRPC was the most logical candidate
Martti T.
Echo is for plain old HTTP(s). You could create http handler for http.Server that redirects flow to grpc server. ala
    if req.Header.Get("Content-Type") == "application/grpc-web+proto" {
        grpcServer.ServeHTTP(w, req)
       e.ServeHTTP(w, req)
Argishti Rostamian
Hi, has anyone used the HTTP-01 challenge type when using Auto TLS in Echo? I have posted some code in https://github.com/labstack/echo/discussions/1884 with more details.
Echo not supporting url path param binding?
The even docs doesn't mention about it