Fiber: 馃悰 dot problem with params in routes

Created on 14 Aug 2020  路  3Comments  路  Source: gofiber/fiber

Fiber version

github.com/gofiber/fiber v1.13.3

Issue description

Params in route not worked

Code snippet

package main

import (
    "fmt"

    "github.com/gofiber/fiber"
)

func main() {

    app := fiber.New()

    grp := app.Group("/.well-known/test", func(c *fiber.Ctx) {
        c.Next()
    })

    grp.Get("/", func(c *fiber.Ctx) { // work
        c.Send("Hello, World 馃憢!")
    })

    grp.Get("/ok", func(c *fiber.Ctx) { // work
        c.Send("OK")
    })

    grp.Get("/js/:name", func(c *fiber.Ctx) { // NOT WORK
        msg := fmt.Sprintf("Hello, %s 馃憢!", c.Params("name"))
        c.Send(msg) // => Hello john 馃憢!
    })

    app.Listen(3000)
}

鈽笍 Bug 馃彿 Wait for Release

All 3 comments

changing

    grp := app.Group("/.well-known/test", func(c *fiber.Ctx) {
        c.Next()
    })

to

    grp := app.Group("/well-known/test", func(c *fiber.Ctx) {
        c.Next()
    })

Will work

solved with PR https://github.com/gofiber/fiber/pull/715

will be included in the next release

at the heart of the problem is that dot is a delimiter, just like dash and slash and the old logic expected something to stand between two delimiters, now the logic is a bit smarter and it just needs to know that it is a delimiter to terminate parameters

Was this page helpful?
0 / 5 - 0 ratings

Related issues

faultable picture faultable  路  3Comments

jeyraj picture jeyraj  路  4Comments

bashery picture bashery  路  4Comments

mewben picture mewben  路  3Comments

petersephrin picture petersephrin  路  4Comments