mirror of
https://github.com/gofiber/fiber.git
synced 2025-05-31 11:52:41 +00:00
🤖 v1.9.5 (#344)
* 🤖 v1.9.5
Co-authored-by: Fenny <fenny@protonmail.com>
This commit is contained in:
parent
ae7d2bd754
commit
e3b777bacf
2
app.go
2
app.go
@ -1,5 +1,5 @@
|
||||
// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
|
||||
// 📝 Github Repository: https://github.com/gofiber/fiber
|
||||
// 🤖 Github Repository: https://github.com/gofiber/fiber
|
||||
// 📌 API Documentation: https://docs.gofiber.io
|
||||
|
||||
package fiber
|
||||
|
@ -1,11 +1,7 @@
|
||||
// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
|
||||
// 📝 Github Repository: https://github.com/gofiber/fiber
|
||||
// 🤖 Github Repository: https://github.com/gofiber/fiber
|
||||
// 📌 API Documentation: https://docs.gofiber.io
|
||||
|
||||
// go test -v -coverprofile cover.out .
|
||||
// go tool cover -html=cover.out -o cover.html
|
||||
// open cover.html
|
||||
|
||||
package fiber
|
||||
|
||||
import (
|
||||
|
4
ctx.go
4
ctx.go
@ -1,5 +1,5 @@
|
||||
// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
|
||||
// 📝 Github Repository: https://github.com/gofiber/fiber
|
||||
// 🤖 Github Repository: https://github.com/gofiber/fiber
|
||||
// 📌 API Documentation: https://docs.gofiber.io
|
||||
|
||||
package fiber
|
||||
@ -624,7 +624,7 @@ func (ctx *Ctx) Params(key string) (value string) {
|
||||
if ctx.route.Params == nil {
|
||||
return
|
||||
}
|
||||
for i := 0; i < len(ctx.route.Params); i++ {
|
||||
for i := range ctx.route.Params {
|
||||
if (ctx.route.Params)[i] == key {
|
||||
return ctx.values[i]
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
|
||||
// 📝 Github Repository: https://github.com/gofiber/fiber
|
||||
// 🤖 Github Repository: https://github.com/gofiber/fiber
|
||||
// 📌 API Documentation: https://docs.gofiber.io
|
||||
|
||||
package fiber
|
||||
|
@ -30,6 +30,9 @@ var paramsDummy = make([]string, 100, 100)
|
||||
|
||||
// New ...
|
||||
func parseParams(pattern string) (p parsedParams) {
|
||||
if pattern[0] != '/' {
|
||||
pattern = "/" + pattern
|
||||
}
|
||||
var patternCount int
|
||||
aPattern := []string{""}
|
||||
if pattern != "" {
|
||||
|
@ -21,6 +21,19 @@ type testCase struct {
|
||||
ok bool
|
||||
}
|
||||
|
||||
func Test_With_Starting_Wildcard(t *testing.T) {
|
||||
checkCases(
|
||||
t,
|
||||
parseParams("/*"),
|
||||
[]testCase{
|
||||
{uri: "/api/v1/entity", params: []string{"api/v1/entity"}, ok: true},
|
||||
{uri: "/api/v1/entity/", params: []string{"api/v1/entity/"}, ok: true},
|
||||
{uri: "/api/v1/entity/1", params: []string{"api/v1/entity/1"}, ok: true},
|
||||
{uri: "/", params: []string{""}, ok: true},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func Test_With_Param_And_Wildcard(t *testing.T) {
|
||||
checkCases(
|
||||
t,
|
||||
@ -181,17 +194,6 @@ func Test_With_With_Simple_Path(t *testing.T) {
|
||||
},
|
||||
)
|
||||
}
|
||||
func Test_With_With_Empty_Path(t *testing.T) {
|
||||
checkCases(
|
||||
t,
|
||||
parseParams(""),
|
||||
[]testCase{
|
||||
{uri: "/api", params: nil, ok: false},
|
||||
{uri: "", params: []string{}, ok: true},
|
||||
{uri: "/", params: []string{}, ok: true},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func Test_With_With_FileName(t *testing.T) {
|
||||
checkCases(
|
||||
|
@ -65,7 +65,7 @@ func (r *Route) matchRoute(path string) (match bool, values []string) {
|
||||
if r.use {
|
||||
// Match any path if route equals '*' or '/'
|
||||
if r.star || r.root {
|
||||
return true, values
|
||||
return true, []string{path}
|
||||
}
|
||||
// Middleware matches path prefix
|
||||
if strings.HasPrefix(path, r.Path) {
|
||||
@ -76,7 +76,7 @@ func (r *Route) matchRoute(path string) (match bool, values []string) {
|
||||
}
|
||||
// '*' wildcard matches any path
|
||||
if r.star {
|
||||
return true, values
|
||||
return true, []string{path}
|
||||
}
|
||||
// Check if a single '/' matches
|
||||
if r.root && path == "/" {
|
||||
@ -191,7 +191,7 @@ func (app *App) registerStatic(prefix, root string, config ...Static) {
|
||||
prefix = "/"
|
||||
}
|
||||
// Prefix always start with a '/' or '*'
|
||||
if prefix[0] != '/' && prefix[0] != '*' {
|
||||
if prefix[0] != '/' {
|
||||
prefix = "/" + prefix
|
||||
}
|
||||
// Match anything
|
||||
|
@ -1,11 +1,6 @@
|
||||
// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
|
||||
// 📝 Github Repository: https://github.com/gofiber/fiber
|
||||
// 🤖 Github Repository: https://github.com/gofiber/fiber
|
||||
// 📌 API Documentation: https://docs.gofiber.io
|
||||
// ⚠️ This path parser was based on urlpath by @ucarion (MIT License).
|
||||
// 💖 Modified for the Fiber router by @renanbastos93 & @renewerner87
|
||||
// 🤖 ucarion/urlpath - renanbastos93/fastpath - renewerner87/fastpath
|
||||
|
||||
// router benchmarks
|
||||
|
||||
package fiber
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user