Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
yorodm
@yorodm:efym.net
[m]
are you using nginx or something like that?
Leandro Salas
@leandroosalas
@yorodm:efym.net yes, I am using nginx, that was my issue. I needed the client_max_body_size
:sweat_smile: thank you for your response.
otherly
@otherly:matrix.org
[m]
Have an endpoint that takes POSTs and has info from the query params. Using bind with field tagged with query. Doesn't seem to work when testing. Works fine if the request is a GET but not as a POST. Also tried tagging the field form and param.
Can see the query params when checking out request.URL in the echo.Context so I can get it working.
Just wondering if I am using the echo tags wrong.
smk
@knasan
Hello, I'm busy right now echo and golang and wanted to ask whether you are currently updating the website or whether there is another error because some pages are returning a 404.
smk
@knasan
Hi, link from website: https://echo.labstack.com/echox/cookbook/file-upload change to https://echo.labstack.com/cookbook/file-upload works. It seems like the links are broken.
Martti T.
@aldas
we are moving documentation site deployment to github pages and are having little trouble with setting up ci flow and custom domain settings.
Martti T.
@aldas

Have an endpoint that takes POSTs and has info from the query params. Using bind with field tagged with query. Doesn't seem to work when testing. Works fine if the request is a GET but not as a POST. Also tried tagging the field form and param.
Can see the query params when checking out request.URL in the echo.Context so I can get it working.
Just wondering if I am using the echo tags wrong.

Query params are not binded for POST. See how it works https://github.com/labstack/echo/blob/dec96f0312ee1e1117366a420c57dd744444d0da/bind.go#L111

you can bind query params explicitly with err := (&DefaultBinder{}).BindQueryParams(c, &payload) in that case http method does not matter. https://echo.labstack.com/guide/binding has notes block describing rules for binding
Patrick Steadman
@ptsteadman
when binding query params to a struct that includes slices, is there a way to set the binder to split on a delimiter? I see it can be done explicitly with BindWithDelimiter with the QueryParamsBinder, but I'd rather not have to manually map all the other struct fields. perhaps I need to create a custom binder?
Martti T.
@aldas

when binding query params to a struct that includes slices, is there a way to set the binder to split on a delimiter? I see it can be done explicitly with BindWithDelimiter with the QueryParamsBinder, but I'd rather not have to manually map all the other struct fields. perhaps I need to create a custom binder?

There is example testcase for e.Bind() and custom delimiter marshaller. Search for usage of https://github.com/labstack/echo/blob/dec96f0312ee1e1117366a420c57dd744444d0da/bind_test.go#L110

Martti T.
@aldas
note: e.Bind() vs e.BindQueryParams() when later is more explicit (no tags magic) it is substantially faster (does not use reflection) and contains information where binding failed in errors as specific fields. Some naive performance benchmarks can be seen in comment https://github.com/labstack/echo/pull/1736#issue-546267518
Patrick Steadman
@ptsteadman
thanks for the guidance!
pyriand3r
@pyriand3r_gitlab
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
@coach-K
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) {
  //Setup
  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)
  c.SetPath("/roaster/:day")
  c.SetParamNames("day")
  c.SetParamValues("monday")
  h := &Handler{roaster}

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

//TEST OUTPUT
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?
pyriand3r
@pyriand3r_gitlab
@coach-K json:"breakfast" not breakfast:"json" ;)
Jose Then
@RappinKraken_twitter
Does anyone have recommendations in using echo with a jamstack ?
Siddharth Prakash Singh
@spsneo
Is there an easy way to insert request id generated from RequestId middleware as one of the default logger header?
KP
@krishna_pratap_twitter
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
@joncfoo
Hah speaking of openapi; is there a openapi doc generator? i.e. build docs based on the server and models?
Kwanghoo Park
@jerry901
Is there any ways to check if c.QueryParam() is empty or not other than using if clauses?
Martti T.
@aldas
@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).
Kukulkano
@Kukulkano
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.
@aldas
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
Kukulkano
@Kukulkano
@aldas Thanks! That was exactly I was looking for. Great :-)
Manolis Stamatogiannakis
@m000
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
@m000
Is there some reason for this behaviour? I'd expect both cases to have the same output.
Dmitrii Okunev (at work)
@xaionaro-guest:matrix.dx.center
[m]
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
@m000
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.
aschiffmann
@aschiffmann

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:

e.Use(middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(0.5)))

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)
@xaionaro-guest:matrix.dx.center
[m]
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)
@xaionaro-guest:matrix.dx.center
[m]
But I would've open an issue anyway: to either use integers or to implement support of floats :)
1 reply
Damien Gallagher
@damogallagher
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
@arun0009
Or you can use the “Skipper” function.
letran3691
@letran3691
hello everyone
I have issues download file, somebody help my thanks
Dmitrii Okunev (at work)
@xaionaro-guest:matrix.dx.center
[m]
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?
Fede
@f.daforno_gitlab
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
@funcelot

I have issues download file, somebody help my thanks

what the issue?

bikashpdash
@bikashpdash
When use cookie in jwt auth not working , {"message":"missing or malformed jwt"}
Code
middleware.JWTConfig{
SigningKey: []byte(os.Getenv("SECRET_KEY")),
TokenLookup: "cookie:Authorization",
}
but when in change TokenLookup to header:Authorization it works properly
Dmitrii Okunev (at work)
@xaionaro-guest:matrix.dx.center
[m]
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 :)
bikashpdash
@bikashpdash
I checked the cookie i stroed is same value as the jwt token
Yassine Rais
@yassinrais
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
fugkco
@fugkco:matrix.org
[m]
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?