Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
pyriand3r
@pyriand3r_gitlab
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?
Iván Álvarez
@ivanape
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
@renta
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...
letran3691
@letran3691
hello
letran3691
@letran3691
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 []
daghaian
@daghaian
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.
@aldas
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)
        return
    }
       e.ServeHTTP(w, req)
Argishti Rostamian
@WhileLoop
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.
AcrylicShrimp
@AcrylicShrimp
Echo not supporting url path param binding?
The even docs doesn't mention about it
But they said that Echo not support it: labstack/echo#1337
AcrylicShrimp
@AcrylicShrimp
Nah, I tested and found that the echo is supporting url parameter binding