Skip to content

Commit 76271bb

Browse files
committed
Implement Fluent Method Chaining for Status and Type Methods Using Generics #3221
1 parent aac1b97 commit 76271bb

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

app.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const Version = "3.0.0-beta.4"
3737
// Handler defines a function to serve HTTP requests.
3838
type Handler = func(Ctx[any]) error
3939

40-
type customCtxFunc = func(app *App[Ctx[any]]) CustomCtx[Ctx[any]]
40+
type customCtxFunc = func(app *App[any]) CustomCtx[any]
4141

4242
// Map is a shortcut for map[string]any, useful for JSON returns
4343
type Map map[string]any
@@ -89,7 +89,7 @@ type Error struct {
8989
}
9090

9191
// App denotes the Fiber application.
92-
type App[TCtx Ctx[TCtx]] struct {
92+
type App[TCtx any] struct {
9393
// Ctx pool
9494
pool sync.Pool
9595
// Fasthttp server
@@ -493,7 +493,7 @@ func DefaultErrorHandler(c Ctx[any], err error) error {
493493
// ServerHeader: "Fiber",
494494
// })
495495
func New(config ...Config) *App[DefaultCtx] {
496-
app := newApp[DefaultCtx](config...)
496+
app := newApp[any](config...)
497497

498498
// Init app
499499
app.init()

ctx.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const userContextKey contextKey = 0 // __local_user_context__
5050
//go:generate ifacemaker --file ctx.go --struct DefaultCtx --iface Ctx --pkg fiber --output ctx_interface.go --not-exported true --iface-comment "Ctx represents the Context which hold the HTTP request and response.\nIt has methods for the request query string, parameters, body, HTTP headers and so on."
5151
//go:generate go run ctx_interface_gen.go
5252
type DefaultCtx struct {
53-
app *App[Ctx[any]] // Reference to *App
53+
app *App[any] // Reference to *App
5454
route *Route // Reference to *Route
5555
fasthttp *fasthttp.RequestCtx // Reference to *fasthttp.RequestCtx
5656
bind *Bind // Default bind reference

ctx_interface.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

group.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
// Group struct
1313
type Group struct {
14-
app *App[Ctx[any]]
14+
app *App[any]
1515
parentGroup *Group
1616
name string
1717

hooks.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ type (
1313
OnListenHandler = func(ListenData) error
1414
OnShutdownHandler = func() error
1515
OnForkHandler = func(int) error
16-
OnMountHandler = func(*App[Ctx[any]]) error
16+
OnMountHandler = func(*App[any]) error
1717
)
1818

1919
// Hooks is a struct to use it with App.
2020
type Hooks struct {
2121
// Embed app
22-
app *App[Ctx[any]]
22+
app *App[any]
2323

2424
// Hooks
2525
onRoute []OnRouteHandler

mount.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
// Put fields related to mounting.
1616
type mountFields struct {
1717
// Mounted and main apps
18-
appList map[string]*App[Ctx[any]]
18+
appList map[string]*App[any]
1919
// Prefix of app if it was mounted
2020
mountPath string
2121
// Ordered keys of apps (sorted by key length for Render)

0 commit comments

Comments
 (0)