Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 01:37
    ZyqGitHub1 starred labstack/echo
  • 00:07
    Hyvi starred labstack/echo
  • Jun 20 22:35
    QiruiSun starred labstack/echo
  • Jun 20 19:41
    aldas commented #1302
  • Jun 20 16:45
    aldas commented #1302
  • Jun 20 16:44
    aldas commented #1302
  • Jun 20 16:02
    aldas commented #1302
  • Jun 20 15:52
    aldas commented #1302
  • Jun 20 15:52
    aldas commented #1302
  • Jun 20 15:51
    aldas commented #1302
  • Jun 20 15:50
    matiniiuu starred labstack/echo
  • Jun 20 15:20
    aldas pinned #1302
  • Jun 20 15:20
    aldas reopened #1302
  • Jun 20 14:09
    ryo-imai-bit starred labstack/echo
  • Jun 20 14:00
    bongster starred labstack/echo
  • Jun 20 13:46
    sw1max starred labstack/echo
  • Jun 20 12:29
    manisenkov starred labstack/echo
  • Jun 20 11:00
    dimtass starred labstack/echo
  • Jun 20 06:31
    konstantinasj starred labstack/echo
  • Jun 20 06:07
    cspital starred labstack/echo
jenil163
@jenil163
can net/HTTP or echo work parallel ? yes then how
jenil163
@jenil163
withcontext funcation work in echo ?
Tim Keller
@geekbozu
https://github.com/labstack/echo/discussions/1810 Anyone have any feedback on this..o
*i'm sure i'm just not doing it right but I can not find out other docs for it, I am implementing the same as other auth middle-ware but its not behaving as i expect....
Tim Keller
@geekbozu
anyone?
Tim Keller
@geekbozu
nvm i figured it out.... in short copy pasting code is bad
AcrylicShrimp
@AcrylicShrimp
Hello, I have a question
I want to validate my values; I followed the example: https://echo.labstack.com/guide/request#validate-data
But it looks like throws errors always. Am I right?
Artur Mustafin
@funcelot
But it looks like throws errors always. Am I right?
do you setup proper http handing? e.Logger.Fatal?
Nia
@fluffy-samurai
I'm experiencing the same thing
I'm using all the proper handling
When I comment out the validation, it works, no errors
But when I add the validation line, it throws a runtime error: invalid memory address or nil pointer dereference
Martti T.
@aldas
Documentation site has not been updated as @vishr seems to be missing in action. Problem with validation is that example has a bug. correct validate would be:
func (cv *CustomValidator) Validate(i interface{}) error {
    if err := cv.validator.Struct(i); err != nil {
        return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
    }
    return nil
}
Leandro Salas
@leandroosalas
Hi Guys!! I am having an issue that I have been looking how to fix now for 2 days.
I am getting a 413 Entity Too large.
I have the BodyLimit configuration in place.
e.Use(middleware.BodyLimit("100M"))
The weird thing is it was working on my local server.
but once I pushed the changes to the server I started getting that message.
I really appreciate any help with this.
Leandro Salas
@leandroosalas
Am i missing something.?
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)!