Questions tagged [go-fiber]

Fiber is an Express inspired web framework built on top of Fasthttp, the fastest HTTP engine for Go.

Fiber is an Express inspired web framework built on top of Fasthttp, the fastest HTTP engine for Go.

167 questions
1
vote
1 answer

Issue with Gofiber framework template

I am in the process of learning fiber framework in GO language and having trouble figure out why the template engine is returning an error when the body section is an include. The following works as expected but when I add in another include for…
jason
  • 1,132
  • 14
  • 32
1
vote
1 answer

Golang GORM data retrieve for many to many relationship with join table

I'm using golang 1.19 and ORM as GORM. I need to retrieve products using category id. Products table and categories table bind with many to many relationship. So 3rd table is product_categories. What I need to do is when get request come with…
Hardy
  • 75
  • 4
1
vote
1 answer

User findOne is returning nil but data is present in Go fiber Go Mongo

i am stuck in a issue where i am trying to fetch the user details by doing err := userCollection.FindOne(ctx, bson.M{"email": input.Email}).Decode(&input) in my user controller but it is returning nil. I have places a mongo.ErrNoDocuments check but…
Biswas Sampad
  • 413
  • 1
  • 6
  • 19
1
vote
1 answer

How to write test for main.go in GoFiber

Below is my code for main.go func main() { app := fiber.New() app.Use(recover.New()) inferenceController := controllers.InferenceController middleware := middleware.Middleware privateRoutes :=…
Taha Khan
  • 69
  • 5
1
vote
1 answer

MongoDB GO driver overwriting existing data

I am using GO-FIBER and using MONGODB MongoDB Go Driver. I want to update only the fields given by the body. But it is overwriting the data. func UpdateOneUser(c *fiber.Ctx) error { params := c.Params("id") body := new(models.User) …
1
vote
0 answers

how to set headers that get from client api in Go

I have a client API where the client API has headers: req.Header.Set("Authorization", tokenBarear) req.Header.Add("Content-Type", "application/json") for token bearer which is set for the time limit. However when I run and test in postman it…
loops
  • 19
  • 1
1
vote
0 answers

How to properly scan postgresql JSON in Golang using pq driver?

I wrote a query to show data from consumer table. Table does have a payment_methods field with type JSON. When i execute update query, its working fine. But i can't find out why error occured to fetch all data. When i try to run this and this…
1
vote
0 answers

cannot use lead.GetLeads (value of type func(c *fiber.Ctx)) as func(*fiber.Ctx) error value in argument to app.Get

I'm trying to build an API in Go lang with fiber(V2) and gorm. When I try to set up the routes with this code : main.go (package main) : func setupRoutes(app *fiber.App) { app.Get("/api/leads", lead.GetLeads) app.Get("/api/leads/:id",…
user18977096
1
vote
1 answer

fasthttp websocket: panic nil: websocket.(*Conn).beginMessage()

Using Fiber v2.38.1, which in turn use fasthttp/websocket v1.5.0. App crashed with following error: 2022-10-15T04:05:42.983563+00:00 app[web.1]: time="2022-10-15T04:05:42Z" level=info msg="close msg received: &{418…
Eric
  • 22,183
  • 20
  • 145
  • 196
1
vote
1 answer

golang Fiber no getting user register ID

I am learning fiber framework and JWT Auth. The register Func and Login Func correctly saves the user Id in the database. The cookie and JWT are are retrieved correctly and displayed the cookie and persisted on the front end. When I attempt to get…
Gerardo
  • 19
  • 2
1
vote
0 answers

How can I clear the Cache middleware in go-fiber?

I'm using the fiber framework of golang. I want to Cache some endpoints in my server. For example: I have endpoint to get all products like this:http://127.0.0.1:8080/products I'm Caching this endpoint but when products table updated I need to clear…
levniko
  • 91
  • 7
1
vote
0 answers

How to keep websocket connections in chat application? (Gorilla websocket )

I am working on the application with chat module which implemented using Angular in Frontend and Golang in Backend. We used RxJS package for websocket in the frontend, Fiber (framework) websocket (Includes Gorilla websocket) in backend. I have few…
Ramarasu R
  • 55
  • 5
1
vote
1 answer

How can we reach claims in fiber.context custom middleware?

I want to set claims to fiber.context. But I got an error in 3th line that is *jwt.Token is empty. How can I reach token or claims ? Or do you have an advice to use anything else. func RoleMiddleware() func(*fiber.Ctx) { //change name return…
levniko
  • 91
  • 7
1
vote
2 answers

How to add different middleware to routes under same sub route in gofiber

I have a route configuration as below with a base route and 5 subroutes under that baseRoute := app.Group("/base") baseRoute.Post("/sub_route1", handler1) baseRoute.Post("/sub_route2", handler2) baseRoute.Post("/sub_route3",…
vignesh
  • 498
  • 8
  • 18
1
vote
1 answer

Stream media file from minio object

I have a backend go fiber server which would serve files fetched from cloud service using minio client sdk. My goal is to achieve video file streaming with out exposing direct connection to cloud url and the video must be seekable, both forward and…
unitoflazy
  • 21
  • 3