2

these is my api and i don't know what is the problem for that endpoints duplicated, i was trying if is something of config but there is not nothing about in their documentation

package main

import (
    "aurora/routes"
    "fmt"

    "github.com/gofiber/fiber/v2"
)

func main() {
    app := fiber.New(fiber.Config{
        AppName: "Aurora Api V1",
    })

    routes.ServerRoutes(app)

    app.Get("/AAAAAAAA", func(c *fiber.Ctx) error {
        return c.JSON("hellow from login")
    })

    routesList := app.GetRoutes()
    for i, route := range routesList {
        fmt.Printf("%d - %d\n", i+1, route)
    }
    app.Listen(":3000")
}
package routes

import (
    "aurora/routes/user"

    "github.com/gofiber/fiber/v2"
)

func ServerRoutes(server *fiber.App) {
    user.UserRoutes(server.Group("/user"))
}


package user

import "github.com/gofiber/fiber/v2"

func UserRoutes(router fiber.Router) {
    router.Get("/login", func(c *fiber.Ctx) error {
        return c.JSON("hellow from login")
    })

    router.Get("/logout", func(c *fiber.Ctx) error {
        return c.JSON("hellow from logout")
    })

    router.Get("/signup", func(c *fiber.Ctx) error {
        return c.JSON("hellow from signup")
    })
}

enter image description here

i want that golang just map GET endpoints not HEAD endpoints, or there a reason for that?

  • A HEAD request is the same as a GET request, but the server does not send the response body. Your server will work as expected with the mapping. – Charlie Tumahai Feb 11 '23 at 18:19

1 Answers1

0

I think HEAD method is used as default for GET routes in Fiber since it's nearly the same thing. Read more about HEAD method in MDN Docs.