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
8
votes
1 answer

panic interface conversion interface {} is float64 not int64

I am getting the following error panic: interface conversion: interface {} is float64, not int64 I am not sure where float64 is coming from here I have type set to int64 but not sure where float64 came from type AccessDetails struct { …
uberrebu
  • 3,597
  • 9
  • 38
  • 73
8
votes
2 answers

In a gofiber POST request how can I parse the request body?

How would I read and change the values if I posted JSON data to /post route in gofiber: { "name" : "John Wick" "email" : "johnw@gmail.com" } app.Post("/post", func(c *fiber.Ctx) error { //read the req.body here name :=…
Erick Li
  • 91
  • 1
  • 1
  • 2
5
votes
2 answers

How to get the decoded token for jwt auth0 and gofiber?

Im using next.js auth0 and a custom golang api backend and I'm having trouble getting the decoded token on the backend side. On the frontend side I followed this tutorial - https://auth0.com/docs/quickstart/webapp/nextjs/01-login and I managed to…
airsoftFreak
  • 1,450
  • 5
  • 34
  • 64
5
votes
0 answers

Gorm take huge time to retrieve data from Postgres

23:28:45 | 200 | 20.294s | 127.0.0.1 | GET | /api/user/cart/product/all From Cart product, I retrieve cart with Cart products. Though Cart has only one Cart with One product. But it takes too much time to retrieve. var cart model.Cart …
4
votes
1 answer

Gofiber how to get the original path in middleware

I have a gofiber routing like this app.Use(func(c *fiber.Ctx) error { fmt.Println(c.Path()) <--- want this to get the original path name `/user/:id` return c.Next() }) app.Get("/user/:id", func(c *fiber.Ctx) error { return…
samithiwat
  • 49
  • 3
4
votes
1 answer

How to dynamically parse request body in go fiber?

I have an API built in go fiber. I'm tryng to parse request body data as key value pairs dynamically. As we know, fiber has context.Body() and context.Bodyparser() methods to do this but I couldn't find any proper example to do this dynamically with…
hamed dehghan
  • 471
  • 7
  • 15
3
votes
2 answers

AWS Cognito JWT verification using Go Fiber middleware (getting "key is of invalid type")

I am getting "key is of invalid type" when I try to verify a Cognito based JWT in my middleware. Currently I set up the middle ware like this when the Fiber app is being setup: // read the "jwks.json" that I got from AWS locally signingKey, err :=…
Anthony Pham
  • 151
  • 2
  • 15
3
votes
2 answers

CORS error for golang fiber with React front-end

I am using golang fiber server, setup like this: package main import ( "go-auth/database" "go-auth/routes" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" ) func main() { database.Connect() app…
Bill Software Engineer
  • 7,362
  • 23
  • 91
  • 174
3
votes
1 answer

With Fiber's context, how do I iterate over multiple files?

When I receive a post request with a list of files to be uploaded to the server, I can get a specific file, if I know the name of it via c.FormFile("filename") But how would I iterate over the files in that list, without knowing the files names…
granitdev
  • 136
  • 2
  • 13
3
votes
2 answers

How to assign a json object in a particular localhost route to a variable in javascript

I am quite new to learning web development and have been stuck for hours and my knowledge of Javascript is not that well. I have a route localhost:8080/api/employee/ so that when I enter this route in my browser it shows a JSON [ { …
sempraEdic
  • 132
  • 9
3
votes
0 answers

How to add custom css to swagger UI in Golang?

I'm working on a Golang project at the moment. As a framework, I use go-fibre. To implement swagger documentation, I utilize swaggo/swag and fibre-swagger. I need to modify my swagger output page (eg: Font size should be increased, colour should be…
Mohamed Arshad
  • 89
  • 1
  • 1
  • 6
3
votes
1 answer

Why is my cookie not being sent? ReactJS front-end, Go back-end

I am working on a personal finance application with a Go back-end (go-fiber framework) and ReactJS front-end. My authentication method is to return a JWT as a cookie when a user signs in. The front end sends a sign-in request using fetch, then…
Jack Timothy
  • 33
  • 1
  • 4
3
votes
2 answers

how do i validate the body structure of rest api request in golang

I am trying to ensure the body of a post request for example contains exact structure of the body and if not ahould throw an error for example i have the following function func UpdatePassword(c *fiber.Ctx) error { type UpdatePasswordData…
uberrebu
  • 3,597
  • 9
  • 38
  • 73
3
votes
1 answer

Send empty response with fiber

I'm building an API, I can't figure out how to return an empty response if most of them are like: func GetEntityInstance(c *fiber.Ctx) error { ... return c.Status(fiber.StatusCreated).JSON(fiber.Map{ "id_created": new_id, …
hestellezg
  • 3,309
  • 3
  • 33
  • 37
2
votes
0 answers

"error decoding key creator: cannot decode objectID into a models.User" using go and mongoDb

I am new to go and mongo so I created a struct user and another struct prompt having a data multiple values and one of them is a creator field with data type as user struct. what I want is to fetch data from prompt collection and then populate the…
Aakash Raj
  • 21
  • 2
1
2 3
11 12