Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 17:12
    stale[bot] labeled #1421
  • 17:12
    stale[bot] commented #1421
  • 08:44
    prabhah opened #1459
  • 08:34
    PettyTailor starred labstack/echo
  • 08:13
    arifnd starred labstack/echo
  • 08:08
    mollion starred labstack/echo
  • 07:51
    lizzzcai starred labstack/echo
  • 06:37
    hoangtn1304 starred labstack/echo
  • 04:40
    lukekhamilton opened #1458
  • 03:40
    xzhdream starred labstack/echo
  • Dec 09 21:09
    stale[bot] labeled #1420
  • Dec 09 21:09
    stale[bot] commented #1420
  • Dec 09 19:09
    stale[bot] labeled #1404
  • Dec 09 19:09
    stale[bot] commented #1404
  • Dec 09 17:48
    miimsam starred labstack/echo
  • Dec 09 15:45
    ammmir commented #1405
  • Dec 09 15:44
    pilvy commented #1405
  • Dec 09 15:44
    pilvy commented #1405
  • Dec 09 14:44
    jjmrocha starred labstack/echo
  • Dec 09 14:18
    kunalbhagawati starred labstack/echo
Oliwer Helsén
@oliwerhelsen
@yavuzyurtbegendi routing with regex is not supported by echo :(
Yavuz Yurtbeğendi
@yavuzyurtbegendi
so how should I create routes like this :) somecategory-c-1435
@oliwerhelsen
I can write a global handler if possible
Oliwer Helsén
@oliwerhelsen
Yeah, i don’t know. This is a significant limitation in echo.
Yavuz Yurtbeğendi
@yavuzyurtbegendi
e.Pre(middleware.Rewrite(map[string]string{
    "/*-c-*": "/category/$1/$2",
}))
e.GET("/category/:slug/:id", func(c echo.Context) error {
    fmt.Println(c.Get("$1"))
    fmt.Println(c.ParamNames())
    fmt.Println(c.ParamValues())
this one works
Oliwer Helsén
@oliwerhelsen
Awesome 👍.
Tom Lester
@tlester
Hi all - I'm new to echo and while not entirely new to golang, this is my first big project in golang. So.. you could say i'm a n00b.
I can't figure out why some of my routes are not working while some are.
    // Routes
    e.GET("/users", h.ListUsers)
    e.POST("/user", h.AddUser)
    e.GET("/user/:email", h.GetUser)
    e.PUT("/blah", h.ModifyUser)
    e.DELETE("/user/:email", h.DeleteUser)

    e.Logger.Fatal(e.Start(":8080"))
}
Those are my routes. in main().
The first three work great.
The third and fourth do not. The third (the PUT) is extremely simplified just because nothing is working.
func (h *Handler) ModifyUser(c echo.Context) error {

    return c.JSON(http.StatusOK, "Got it!")
}
However... I get a 404.
curl -X PUT http://localhost:8080/blah
{"message":"Not Found"}
Tom Lester
@tlester
Can someone explain to me why only the first three routes work and nothing else?
Michael Aldridge
@the-maldridge
iirc this is a limitation of the router
derfenix
@derfenix_gitlab
Hello! Have a question about request's Context - is there any way to update it? I need to put some data to request's context, but can't find a way to do it. WithContext returns new Request, so guess I need to use it, but again - can't find how.
oops. Found SetRequest. Sorry :)
Mohamad Aqib
@mahaqmi_gitlab
@vishr Apparently theres a problem with autoTLS. Echo v4.1.11 uses v1 autocert api. When is the next update for echo? Hopefully @vishr can update with latest v2 api. I tried changing the link for it to uses v2 but another problem arises
Tom Lester
@tlester
Hi all. I have this code:
    e := echo.New()
    e.Use(middleware.Logger())
    r := e.Use(middleware.JWT([]byte("secret")))
And I get this error when I try to build: e.Use(middleware.JWT(([]byte)("secret"))) used as value
Michael Aldridge
@the-maldridge
e.Use doesn't return anything
if I had to guess, what you want is r := e
but in that case you should just call it r from the beginning
Tom Lester
@tlester
Never mind.
I just realized what I did.
@the-maldridge What you said.
Michael Aldridge
@the-maldridge
very rarely, I can spot errors
Tom Lester
@tlester
I was trying to run a method and assignment at the same time.
TheAkhor
@TheAkhor
@oliwerhelsen I have created an example regarding the "bind" unknown type issue I'm having. You said to use middlewear, but I don't know how that would help in the echo bind. If you could point me in the right direction I would be greatful! https://play.golang.org/p/ayw4iOWtM9s
João Eudes Lima
@joaoeudes7
How use Echo in mode Development? Watching changes in files
TheAkhor
@TheAkhor
@joaoeudes7 Install "gin" then you simply run your program by "gin run <golang program name>" ex "gin run server.go"
mohamad aqib abas
@mohdaqib_gitlab
Hi @vishr is there any notice when the next echo version going to be release. Im hoping that the TLS registration issue can be fixed. The current one using v1 api for acme instead of v2. They already terminate the v1 api endpoint. https://community.letsencrypt.org/t/end-of-life-plan-for-acmev1/88430
Nonny Psk
@ivybridge-3c33
Hi how to use context in template funcmap?
mohamad aqib abas
@mohdaqib_gitlab
Im kind of new with prometheus. I managed to get a proper prometheus metrics prompt for my website.com/metrics. however when i ry to use grafana (supposedly to get better visualization for the metrics?) im unable to add the datasource. Do i have to install prometheus on my server too?
Tom Lester
@tlester
Hi all !
Tom Lester
@tlester
I have a Struct has a slice of another struct in it.
That data represents a json with nested elements that an endpoint would receive.
The Struct that contains the other structs is called "User".
Then, I have
u := new(model.User if err := c.Bind(u); err != nil { return err }
I have no idea why the ``` code formatting isn't working
Tom Lester
@tlester
Anyway... I hope you can understand what I'm trying to communicate. The c.Bind(u) is binding everything except for the nested Structs.
What am I doing wrong?
Mohammed Abubakar
@moh-abk

i've a handler;

func Create() func(ctx echo.Context) error {
    return func(c echo.Context) error {
        var country models.RestaurantCountry

        if err := c.Bind(&country); err != nil {
            return echo.ErrBadRequest
        }

        restaurantCountry, err := RestaurantCountryModel.Create(country)
        if err != nil {
            we, _ := err.(mongo.WriteException)
            writeErr := we.WriteErrors[0]
            switch writeErr.Code {
            case errorDuplicateKey:
                return echo.NewHTTPError(409, "Conflict: Restaurant Country already exists")
            default:
                return echo.ErrInternalServerError
            }
        }
        return c.JSON(http.StatusCreated, map[string]models.RestaurantCountry{
            "data": restaurantCountry,
        })
    }
}

I now want to test this handler;

func TestRestaurantCountryCreate(t *testing.T) {
    e := echo.New()
    req := httptest.NewRequest(echo.POST, "/v1/admin", strings.NewReader(restaurantCountryJSON))
    req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
    rec := httptest.NewRecorder()
    c := e.NewContext(req, rec)
    c.SetPath("/restaurants/countrys")

    h := Create()

    // Assertions
    if assert.NoError(t, h) {
        assert.Equal(t, http.StatusCreated, rec.Code)
    }
}

the error I'm getting is;

Cannot use 'h' (type func(ctx echo.Context) error) as type error Type does not implement 'error' as some methods are missing: Error() string

any ideas?