Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 05:49
    ikedam commented #1974
  • 03:05
  • Dec 03 22:28
    lukasmrtvy starred labstack/echo
  • Dec 03 15:50
    adotsloan starred labstack/echo
  • Dec 03 14:50
    gamemaker1 starred labstack/echo
  • Dec 03 10:03

    lammel on master

    stream decompression instead of… (compare)

  • Dec 03 10:03
    lammel closed #2018
  • Dec 03 10:03
    lammel commented #2018
  • Dec 03 03:20
    isso-719 starred labstack/echo
  • Dec 03 02:10
    xxwang starred labstack/echo
  • Dec 02 21:35
    aldas commented #2038
  • Dec 02 21:35
    aldas commented #2038
  • Dec 02 21:32
    aldas commented #2036
  • Dec 02 21:29
    aldas labeled #2036
  • Dec 02 21:29
    aldas labeled #2036
  • Dec 02 20:48
    minaminao starred labstack/echo
  • Dec 02 20:18
    nh43de starred labstack/echo
  • Dec 02 19:10
    davidmdm commented #2018
  • Dec 02 16:54
    ioppermann commented #2038
  • Dec 02 16:54
    ioppermann commented #2038
Martti T.
@aldas
just implement layered architecture in our application and design HTTP and GRPC handlers in your transport layer that extract their data and pass it t your business service layer.
search for "Onion Architecture" / "Hexagonal Architecture"
Martti T.
@aldas
quick googling gives me for Go https://blog.kinark.app/post/onion-architecture/ which seems decent article
1 reply
Andrey Grehov
@andreygrehov_twitter
Hello. Does Echo have some sort of a retry mechanism on panics?
I noticed a paniced request flow is being retried 3 times, can't understand why would that happen
Andrey Grehov
@andreygrehov_twitter
nvm, it's chrome's weird behavior..
Maksimilian
@trendeeze_twitter
how can I access the requestId from the context?
ali naseri
@alinaserinet
Hi dears
Why does this error occur in Echo? "Please provide valid credentials"
Matthias
@matthias:bsr.mn
[m]
hi! is it possible to use the proxy middleware to proxy a unix socket? I am getting {"message":"remote unix:///tmp/ttyd.sock unreachable, could not forward: unsupported protocol scheme \"unix\""}
Matthias
@matthias:bsr.mn
[m]
if it's not possible I'd like to open a feature request on github
Martti T.
@aldas

You could try

    proxyConf := middleware.ProxyConfig{
        // your other settings
        Transport: &http.Transport{
            DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
                return net.Dial("unix", addr)
            },
        },
    }
    e.Use(middleware.ProxyWithConfig(proxyConf))

maybe it works.

3 replies
Matthias
@matthias:bsr.mn
[m]
panic: echo: proxy middleware requires balancer

goroutine 1 [running]:
github.com/labstack/echo/v4/middleware.ProxyWithConfig({0x1319698, {0x0, 0x0}, 0x0, 0x0, {0x0, 0x0}, {0x13641a0, 0xc00013d040}, 0x0})
    /Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/middleware/proxy.go:214 +0x1aa
main.main()
    /Users/matthias/apigw/server.go:62 +0x194
exit status 2
`
should I just pass an empty balancer?
with an empty balancer:
echo: http: panic serving [::1]:61352: runtime error: invalid memory address or nil pointer dereference
goroutine 6 [running]:
net/http.(*conn).serve.func1()
    /usr/local/Cellar/go/1.17.2/libexec/src/net/http/server.go:1801 +0xb9
panic({0x12b0840, 0x154adf0})
    /usr/local/Cellar/go/1.17.2/libexec/src/runtime/panic.go:1047 +0x266
net/http/httputil.NewSingleHostReverseProxy(0x0)
    /usr/local/Cellar/go/1.17.2/libexec/src/net/http/httputil/reverseproxy.go:144 +0x1d
github.com/labstack/echo/v4/middleware.proxyHTTP(0xc0000668a0, {0x13736f0, 0xc00018c460}, {0x1319778, {0x136a6a0, 0xc0000134e0}, 0x0, 0x0, {0x0, 0x0}, ...})
    /Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/middleware/proxy.go:279 +0x45
github.com/labstack/echo/v4/middleware.ProxyWithConfig.func1.1({0x13736f0, 0xc00018c460})
    /Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/middleware/proxy.go:260 +0x5d0
github.com/labstack/echo/v4.(*Echo).add.func1({0x13736f0, 0xc00018c460})
    /Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/echo.go:552 +0x51
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc000014fc0, {0x136a8e0, 0xc00017e2a0}, 0xc00019e000)
    /Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/echo.go:662 +0x3bc
net/http.serverHandler.ServeHTTP({0xc0001917d0}, {0x136a8e0, 0xc00017e2a0}, 0xc00019e000)
    /usr/local/Cellar/go/1.17.2/libexec/src/net/http/server.go:2878 +0x43b
net/http.(*conn).serve(0xc00018c3c0, {0x136bb00, 0xc0001916e0})
    /usr/local/Cellar/go/1.17.2/libexec/src/net/http/server.go:1929 +0xb08
created by net/http.(*Server).Serve
    /usr/local/Cellar/go/1.17.2/libexec/src/net/http/server.go:3033 +0x4e8
Martti T.
@aldas
you need balancer. What that Transport.DialContext does is that it will use unix socket instead of tcp for initiating the connection.
4 replies
Matthias
@matthias:bsr.mn
[m]
will try later
Yeah I am very new to go. Literally just started today
Thanks for the pointers
Martti T.
@aldas
np
Matthias
@matthias:bsr.mn
[m]

when proxying multiple things like:

serverA -> /
serverB -> /api

can I make serverA not overwrite serverB on /api? Because I can't figure it out haha

Matthias
@matthias:bsr.mn
[m]
ah nevermind I am blind
skipper seems to work for this purpose
Berke Soysal
@BerkeSoysal
is it possible to take multiple http parameters with the same identifier?
1 reply
Matthias
@matthias:bsr.mn
[m]
Request query returns an array always
6 replies
Matthias
@matthias:bsr.mn
[m]

question. I am trying to add a custom middleware which changes both method and path (I know there are existing middlewares for both and I checked their source)

        req := c.Request()
        req.Method = "PUT"
        path := req.URL.Path
        url, _ := req.URL.Parse(path + "/9")
        req.URL = url

This succeeds in changing the method, but it fails changing the path, any idea what's up with that?

Matthias
@matthias:bsr.mn
[m]
just to be clear, I am using my middleware with e.Preas recommended
Matthias
@matthias:bsr.mn
[m]
Nevermind. Worked around it another way
Martti T.
@aldas
@matthias:bsr.mn could you explain your (business) use-case (why/when) for changing method/path?
1 reply
Matthias
@matthias:bsr.mn
[m]
i mean the proxy middleware works just fine for websockets, but not while proxying unix sockets haha
Yagyesh Srivastava
@T0D0-FIXME

I am facing the "No token found " when I try to use echo framework for expositioning my metrics and using prometheus to scrape them.
While instrumenting my labstack echo web server with prometheus, I followed the example here: https://echo.labstack.com/middleware/prometheus/
and didnt instrument any custom metrics yet, still not able to get it to work with prometheus scraper with just the basic echo framework metrics. Following is the scrape config that I used:

- job_name: 'nebula-staging'
  static_configs:
  - targets: ['10.X.Y.Z:8000']
    labels: 
      instance: 'nebula'

Also, I am able to curl to this address and get the metrics, when I use promtool to check the metrics for any inconsistency I dont find any. Not too sure what to do, does anyone have any clue? Would be of great help, thanks!

Nino
@ninom4ster:matrix.org
[m]
Hello! I was wondering if Echo supports adding/removing routes while it's running or do I have to restart it?
1 reply
Nino
@ninom4ster:matrix.org
[m]
alright. thanks!
Tornike Razmadze
@torniker

Hi, I have been stuck trying to configure my echo app to serve with https, but have no success. I've read and tried this: https://echo.labstack.com/cookbook/auto-tls ..

So at this point i am getting following error:
echo: http: TLS handshake error from {some-ip}:27002: acme/autocert: unable to satisfy "https://acme-v02.api.letsencrypt.org/acme/authz-v3/53188301650" for domain "mydomain.com": no viable challenge type found

2 replies
Thomas Elsgaard
@elsgaard
Hi everybody! I am serving index.html which loads css, js etc.by using e.Static("/dashboard", "/web"), BUT i would like to retrieve the query params. How can i achieve this? How do i call a normal handler like e.GET and get the query params, and then return either the path to /web or the specific index.html file ?
jahidmixmaster
@jahidmixmaster
Hi everybody, I saw a CRUD example here (https://echo.labstack.com/cookbook/crud/). My question is Variable Users and Seq both are not Go routine safe (thread-safe). Two Goroutines can access both Variables at the same time.
Martti T.
@aldas
these variables are not thread safe. maybe for shorter example sync.mutex is left out. anyway - in real world you would use some proper storage engine and their locking mechanisms
jahidmixmaster
@jahidmixmaster
Thank you so much.
porty
@tqrj
hello
Parsing JSON request data appears not to be supported?
I have to parse it manually
image.png
Martti T.
@aldas
porty
@tqrj
ok thank
danvenn
@danvenn
Hey all
I'd like to create a test that I can hand a path to and echo will route for me and send it to the appropriate handler
Has anyone here done that before? So far I can only find documentation for manually giving it a specific handler function
This message was deleted
Something like this doesn't seem to return anything
func GETTER(path string, params []string, paramValues []string) string {
    e := echo.New()
    req := httptest.NewRequest(http.MethodGet, path, nil)
    rec := httptest.NewRecorder()

    c := e.NewContext(req, rec)

    c.SetParamNames(params...)

    //res := rec.Result()
    defer rec.Result().Body.Close()
    c.SetParamValues(ClientIdString)

    //controllers.GetFullProfile(c)
    return rec.Body.String()
}