Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 15:22
    MoonNarga starred labstack/echo
  • 15:19
    lecram starred labstack/echo
  • 14:26
    tekinpolat starred labstack/echo
  • 12:51
  • 12:33
    cvngur starred labstack/echo
  • 09:57
    clwluvw review_requested #1789
  • 09:57
    codecov[bot] commented #1789
  • 09:56
    codecov[bot] commented #1789
  • 09:52
    codecov[bot] commented #1789
  • 09:52
    codecov[bot] commented #1789
  • 09:52
    codecov[bot] commented #1789
  • 09:52
    codecov[bot] commented #1789
  • 09:52
    codecov[bot] commented #1789
  • 09:51
    codecov[bot] commented #1789
  • 09:51
    codecov[bot] commented #1789
  • 09:50
    clwluvw synchronize #1789
  • 09:50
    codecov[bot] commented #1789
  • 09:47
    yuchunzhou starred labstack/echo
  • 09:46
    codecov[bot] commented #1789
  • 09:46
    codecov[bot] commented #1789
Ase Deliri
@deliri
Also if there is a way to pass the ID from the HTML template which initially loads with that ID available as a variable back into the anchor tag that eliminates having to clean up the end result URL, that would be great too
Gaadek
@Gaadek

Hi all,

Do you have any guidance on how to serve object storage data without having to download them locally?
Up to now, for my mockup, the solution I implemented is request -> dl S3 file locally -> echo response with a link to the local file

This is pretty ugly, shame on me. But right now, I don't know how to manage that another way, nor when I can remove the temporary files.

Petr Vítek
@rattuscz
Hi,
can i safely share echo.Context from route handler to goroutine? mainly to allow getting request data while logging errors:
go func(c echo.Context) {
    if err = callApi(); err != nil {
        logError(c, err)
    }
}(c)
Ion
@Bordian_gitlab
@Gaadek I think echo (unfortunately) does not have a solution for this, but you can through golang's api; found one article: https://www.socketloop.com/tutorials/golang-how-to-stream-file-to-client-browser-or-write-to-http-responsewriter
Maia
@maiacodes
Is it possible to use Echo on an existing net/http server/mux?
Robert
@End-S
Does anybody know if I can get Echo to error when an unexpected query param is passed?
Robert
@End-S
Ah okay, looks like it would not be very good security practice to error on unexpected query params
Dustin Currie
@dustinevan
Hi everyone. I'm brand new here. Could someone direct me to a place that talks about how to recover from panics in goroutines created during request handling? Looks like the recover middleware doesn't do this.
Gustavo H. M. Silva
@gustavohmsilva

Brand here new as well, Have always worked with net/http but the company I'm starting with uses echo. I'm a little bit lost as of how to do dependency injection in echo :|

Anyone has a boilerplate example of how to do this in github?

unkn0wnx33
@unkn0wnx33
hi, is anyone here that is familiar with the echo websocket? i am totally lost rn :/
Jax
@liua0
hi, anyone here?
Arun Gopalpuri
@arun0009
@dustinevan - well your goroutines are a totally different thread, so recover middleware won’t help with that as you outside the request lifecycle if that makes sense?
@gustavohmsilva - you from java spring world :) If you need dependency injection in go, interface is your friend ;)
@liua0 - echo back(pun intended) to your "anyone here"
Evans Mungai
@banjoh
Hi everyone. Is there a way to detect duplicate routes? I'm considering using e.Routes() to inspect them and panic if I see duplicates but I was hoping to have a built in API or something of the sort. At the moment the last duplicate route handles the request, which makes sense given how the router resolves routes
Sadiqur Rahman
@sadiq1971
I am using echo for go micro-services. Now i am adding grpc for my services but there will be a http proxy on top of grpc. I can do that with grpc-gateway but i want to keep echo framework as well. Is there any way to do that? Or i need to completely shift from echo?
Arun Gopalpuri
@arun0009

@sadiq1971 - grpc-gateway uses mux, so you could technically wrap it something like this (haven’t tested, but general idea).

I wouldn’t add echo to the mix and complicate but just stick with grpc-gateway unless you have a lot of routes.

    mux := runtime.NewServeMux()
    opts := []grpc.DialOption{grpc.WithInsecure()}
    err = apiv1.RegisterXXXXXHandlerFromEndpoint(ctx, mux, fmt.Sprintf("localhost:%s", env.GRPCServerPort), opts)
    if err != nil {
        return err
    }

    e := echo.New()
    e.Any("/api/*", func(c echo.Context) error {
        mux.ServeHTTP(c.Response(), c.Request())
    })
mokamars
@mokamars
Hi everyone, I'm new to GO and ECHO, and I encounter a problem that I can't solve. I cannot maje the go get command with th v4 at the end ? And I cannot import using v4 as well. Do you have an idea what the problem is ? Thx
Roland Lammel
@lammel
See https://echo.labstack.com/guide . I guess you are using Go < 1.15
mokamars
@mokamars
Hi @ lammel : I finally found, I didn't know to mangage dependencies with a go.mod file. Now it is wirking. Thx
Rahul Ram
@rahul8590
hey folks, I was looking through echo framework doc. I was wondering, if echo has WAF (web application firewall ) support. If not, whats the best way to safeguard web server written using echo?
naoufal zerai
@naoufalzerai
Hi all is there any way to know if the client is still connected if we are using sse ?
naoufal zerai
@naoufalzerai
Sorry I found it :D c.Request().Context().Done()
Aman ojha
@007aman
Hi @all i an beginner on golang i use echo i create controller folder seprate and import in main.go but it auto remove every time?
mttrung
@mttrung
Hi guys, when using middleware.BasicAuth(), how can I store user info into context for later use?
Luís Melo
@luisfmelo
Hi Guys, I have a little issue here.
So, I have an echo API. In my controller, after the creation of a resource, I have a go function to make audit (via gRPC).
I'm integrating jaeger and it requires the parent context (HTTP controller).
The issue is that it all functions well except for the jaeger tracing because the context of the HTTP request is cancelled (the request ends) and in jaeger, I see that as an error.
Is there any way to keep the context alive while there are go functions running?
I'm thinking of holding an wait group in the context and control the execution with that but it is a lot of magic happens that I will be the only one knowing about.
Arun Gopalpuri
@arun0009
@luisfmelo sounds similar to this issue census-instrumentation/opencensus-go#987 You just need pull span fromContext and pass it.
Luís Melo
@luisfmelo
Thanks @arun0009! But unfortunately, I'm using opentracing lib.
Arun Gopalpuri
@arun0009
@luisfmelo sure but isn’t it due to you using request context and using go routine that you seeing cancelled traces? Think you should use a different context like context.Background so they aren’t part of original request isnt it?
Btw even Im heavily invested in tracing right now and i’m using zipkin-go and brave for scala/jvm languages tracing
Arun Gopalpuri
@arun0009

Not sure if this is a bug but I want to have some routes + reverse proxy on any other routes. To achieve this I have set up echo routes as :

e := echo.New()
e.GET(“/ping”, pingHandler)
e.GET”/pong”, pongHandler)
e.Any(“/*”, reverseProxyHandler)

When I call http://localhost:8080/ping, I see it calling pingHandler and reverseProxyHandler.

14 replies
jenil163
@jenil163
how to use pathparam using echo fremwork
1 reply
Hyunwoo Lee
@aeharvlee
Hi guys, I got a cors error :(
and I give middleware configs like below but does not work T_T
    e := echo.New()
    e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
        Skipper:          nil,
        AllowOrigins:     []string{"*"},
        AllowMethods:     []string{http.MethodGet, http.MethodPut, http.MethodPost, http.MethodDelete},
        AllowCredentials: false,
        ExposeHeaders:    nil,
        MaxAge:           0,
    }))
Is there anyone who are in cors trouble like me ?_?
shiwoopark
@Shiwoo-Park
Hello, I just installed echo and put these code in main()
but my vscode shows red line in middleware.Logger()
which says, cannot use middleware.Logger() (value with invalid type) as echo.MiddlewareFunc value in argument to e.Use
Anyone has an idea about this?
    e := echo.New()

    // Middleware
    e.Use(middleware.Logger())
I resolved the issue by doing these
go mod init
go mod tidy
jenil163
@jenil163
echo framework is initialised using dependency injection principle.. ?
jenil163
@jenil163
echo framework is initialised using dependency injection principle.. ?
@all
Saint-Jacques
@saintjacques_gitlab
Hello everyone, do I need to configure the timeout in echo, as in http? Thanks
nihiluis
@nihiluis
does echo use different cors for http2? chrome apparently does a http2 request and the allow origins header isnt set by my echo server.
nihiluis
@nihiluis
can I disable http2? ir is it disabled by default? Im confused why chrome even performs an http2 request
Mike Nelson
@realrunner
Is it possible to modify the request context in middleware?
Arun Gopalpuri
@arun0009
Yes you can, we do that in one of our tracing middleware
AleXzpm
@AleXzpm
any good examples of using redis inside a REST api written in echo?
Artur Mustafin
@funcelot

general surface qustions related to #echo are ok to ask here?

https://github.com/funcelot/go-experimentalcommunity.org/

Joshua Schmitt
@pixelsquared
Is there a easy way to use the new go embed feature with echo?
https://tip.golang.org/pkg/embed/
I would like to serve files with the echo static middleware from files embedded with go embed.
Krasimir Popov
@kjpopov
Hi all, any idea of how to use middleware to minify html templates, I am trying to somehow use https://github.com/tdewolff/minify#middleware but I am not able to hook the things together :(
Arthur_kamau
@Arthur-Kamau
hello all, is there any way to prevent status 304, when i clients fetching an image
lab coo
@labcoo_gitlab

I set CORS setting as

    e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
        AllowOrigins: []string{"http://localhost:3000"},
        AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept},
        AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},
    }))

From the browser, when I access the API server(http://localhost:9000) built with it, got Access to XMLHttpRequest at 'http://localhost:9000' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource..

AllowOrigins: []string{"http://localhost:3000"}, doesn't work?