Questions tagged [go-echo]

Echo is a high performance, extensible, minimalist Go web framework. This tag should be used with general questions concerning the Echo framework or any related middleware,

The Echo web framework by LabStack is designed to be minimalist yet high performing.

You can get started by looking at:

144 questions
0
votes
0 answers

Nuxt 3 csrf token issue

I am actually a backend developer but recently I became curious about nuxt3 and started developing a basic CRUD app. I created two separate apps for BE and FE for BE I used Go with Echo, but when I try to implement the CSRF token middleware to the…
ersincebi
  • 41
  • 9
0
votes
0 answers

How to set cookies in projects with different domains?

Currently, there is golang api server and react client, golang server = api.v1.localhost:8081 react client = localhost:3000 I try to log in, if successful, golang sets a cookie like the code below. c.SetCookie(&http.Cookie{ Name: …
madol
  • 551
  • 2
  • 17
0
votes
0 answers

Go lang concise way to pass optional or set default parameters

Go lang functions don't support default or optional params, I don't see any clean way of doing it. here is my sample code: type generatedTemplateParams struct { promptText string templateText string isPromptByHuman …
AtiqGauri
  • 1,483
  • 13
  • 26
0
votes
1 answer

Unit testing a HTTP handler that returns a stream of multiple files

HTTP handler I have a HTTP handler like this: func RouteHandler(c echo.Context) error { outs := make([]io.Reader, 5) for i := range outs { outs[i] = // ... comes from a logic. } return c.Stream(http.StatusOK,…
Megidd
  • 7,089
  • 6
  • 65
  • 142
0
votes
0 answers

How to make a path parameter optional in Go Echo Routes?

Is it possible to have optional "path" parameters in Echo routes? For example, I have GET /user/:userId end point. But I need to call this endpoint without userId also and fall back to the default behavior using the same handler. Currently, if I…
Minudika
  • 851
  • 6
  • 23
0
votes
1 answer

How to handle SPA urls correctly in Golang?

I am trying to embed and serve my frontend (nextjs with static export) with echo. I am currently using: //go:embed all:frontend/out var FrontendFS embed.FS func BuildFrontendFS() http.FileSystem { build, err := fs.Sub(FrontendFS,…
Cemre Mengü
  • 18,062
  • 27
  • 111
  • 169
0
votes
1 answer

How to put meaningful custom status text for custom status codes in Go's echo framework?

func (api *API) sendResponse(c echo.Context, ...) error { ... if ok { if evt.Error != nil { return c.JSONBlob(statuscodes.HttpStatusDiagnosticsCheckError, resBytes) } } return c.JSONBlob(http.StatusOK,…
0
votes
2 answers

How to strconv in echo c.param?

Could anyone advise how to overcome this problem please ? func GetUserController(c echo.Context) error { id := c.Param("id") finduser := users[id] return c.JSON(http.StatusOK,finduser)} var users []User type User struct { …
wupssie
  • 39
  • 3
0
votes
1 answer

Golang Echo - middleware still executing next route when not returning next

I am trying to use an authentication middleware that checks if the user is currently connected and have a session before executing a route, but it seems like my middleware is not stopping the execution of the route and executing the next one even I…
turtle
  • 69
  • 1
  • 5
0
votes
1 answer

NuxtJs Page Redirection With Backend

I am building a website that include payment option with NuxtJs. But I am getting CORS error when i want to rediect to payment page of virtual POS integrator. On backend side I am using Golang/Echo like this: func startPaymentProcess(c echo.Context)…
emre
  • 41
  • 6
0
votes
1 answer

cannot use func literal (type func(string, string, echo.Context) bool) as type middleware.BasicAuthValidator in argument to middleware.BasicAuth

I want to apply Basic authentication in golang using echo framework. I have following error : "# command-line-arguments .\main.go:44:29: cannot use func literal (type func(string, string, echo.Context) bool) as type middleware.BasicAuthValidator in…
0
votes
0 answers

SQL keeps opening a socket, which causes too many open files error. Is there a better way to handle SQL connections in GO?

I have an API in GO using echo and SQL Server as the DB. I use db.Ping() at the start of every endpoint to check if the db is still connected or not, this keeps opening new connections to the db with new sockets which eventually leads to a too many…
Arsh Malik
  • 36
  • 1
  • 2
0
votes
1 answer

Different api responses for same object values

This is the code example: func GetValue(c echo.Context) error { //other implementation details value, err := service.GetValue() if err != nil { return c.JSON(http.StatusBadRequest, errorresponse.Error(4003, err)) } …
Barış Velioğlu
  • 5,709
  • 15
  • 59
  • 105
0
votes
1 answer

Please tell me how to bind multi-array to struct

type _getData struct { Title string `json:"title" form:"title"` Date string `json:"date" form:"date"` Pages []struct { Order int `json:"order" form:"title"` Description string `json:"description" form:"description"` } `json:"pages"…
Choi yun seok
  • 309
  • 2
  • 15
0
votes
1 answer

How to bind multipart/form-data array in Echo framework?

I'm writing an api server using flutter and Go Echo framework, I want to send data from flutter to Go and save it, but c.bind() doesn't work in Go: type _getData struct { Title string `json:"title" form:"title"` Address string …
Choi yun seok
  • 309
  • 2
  • 15