Closed Fenny closed 2 years ago
Features I'm thinking might go with v3
FEATURE 1: Include some features in gofiber client? 1) Timeout 2) Retry mechanism 3) Throttle
FEATURE 2: I think implementing global template layout also a good idea (including option to add properties to template. For e.g.
app := fiber.New(fiber.Config {
...
Template: html.NewFileSystem(...),
TemplateLayout: "layouts/main",
})
// Some fiber middleware to add properties to template
app.Use(func (c *fiber.Ctx) error {
c.LayoutProperty("auth", "blabla")
return c.Next()
})
// At this point, fiber would auto load view on above mentioned layout including all the properties from middleware
// It would work like it's currently working if user provide layout as 3rd param
// The properties would be available throughout the view file and layout
app.Get("/login", fiber(c *fiber.Ctx) error {
return c.Render("views/login")
}
Hope v3 app.static support embed
static will probably not be rewritten, rather use the filesystem middleware, it currently does not work perfectly with embed, think here you can test again and possibly create a feature report, with which we give better support for embed FS in the filesystem middleware, but otherwise this is usable for now
but let's discuss this somewhere else, otherwise we will spam the v3 thread
I want to be able to generate API interface documents automatically.
need more documents and examples with different language
"Suggestions for next update" The "caching properties of cookie so it's user friendly" suggested here: https://github.com/gofiber/fiber/issues/1127
I want to be able to disable global layout in special handlers. For e.g.
app := fiber.New(fiber.Config {
...
TemplateLayout: "layouts/main",
})
// disable global layout by passing "" to 3rd param
app.Get("/login", fiber(c *fiber.Ctx) error {
return c.Render("login", fiber.Map{}, "")
}
im suggest that we can
@micross Isn't it working with empty string in c.Render("login", fiber.Map{}, "")
. I checked the current logic and it seems it works as expected i.e. it will disable global layout by passing "" to 3rd param
https://github.com/gofiber/fiber/blob/master/ctx.go#L958-L962
@sujit-baniya maybe it's a bug in jet template engine, it says 'template / could not be found'.
./views/index.jet
<h1>in index</h1>
./views/layouts/main.jet
<h1>in layout main</h1>
{{ embed() }}
app := fiber.New(fiber.Config{
Views: engine,
ViewsLayout: "layouts/main",
})
app.Get("/", func(c *fiber.Ctx) error {
return c.Render("index", fiber.Map{}, "")
})
https://github.com/gofiber/template/blob/master/jet/jet.go#L220-L229
@micross Yes it's a bug, I added a PR for above: https://github.com/gofiber/template/pull/135/files
v3 need to support gqlgen and jwt for gqlgen :D
We decided to wait with v3 until Go1.18 is released in early 2022 along with generics 🥳
Keep you updated!
PS: Thanks for all the suggestions, keep them coming!
- remove timeout middleware
- fiber.Client is stable and available
- add similar https://github.com/labstack/echo/blob/master/middleware/request_logger.go
I sent pr https://github.com/gofiber/contrib/pull/20 to support zap. But adding multiple logger seems better than my way. I can send PR if maintainers are OK.
Add support for HTTP/3 QUIC.
Split fasthttp methods as engines/fasthttp. Community can create own engine bindings like net/http. Similar to https://github.com/labstack/echo/tree/v2.2.0/engine but only fasthttp supported as builtin in fiber repo.
Change *fiber.Ctx
into an interface
so it's possible and easy to do unit test without the help of net/http/httptest
.
- 🚀HTTP/2 支持 #1541
- 添加头盔、keyauth、重定向、重写到光纤存储库。
@efectn hi, Will the V3 version support http2?
- 🚀HTTP/2 支持 #1541
- 添加头盔、keyauth、重定向、重写到光纤存储库。
@efectn hi, Will the V3 version support http2?
Fiber is built on fasthttp, so ask there.
- 🚀HTTP/2 支持 #1541
- 添加头盔、keyauth、重定向、重写到光纤存储库。
@efectn hi, Will the V3 version support http2?
I don't know but i hope. That's maintainers' decision.
Explore more effective and efficient development mode, such as: support generic, more convenient tools, built-in OpenAPI doc etc.
Maybe we can add the possibility to create hooks to fiber app to everytime a new handler is registered. So in this way the user can make a way to generate a documenting page for their api
How about a CLI command to list all routes? Many web frameworks support this one.
For example:
buffalo routes
(https://gobuffalo.io/en/docs/helpers/)php artisan route:list
(https://laravel.com/docs/8.x/artisan)Automatic swagger documentation could be helpful for my case.
split context into the req, resp and others (like next)
c.Req.GetHeaders()
c.Resp.GetHeaders()
c.Next()
Should write with net/http for catching innovations. (While I was writing this comment, my hands trembled but I am ready for lynch.)
An official implementation of burst limiter would be nice in v3, similar to this #486. As a separate middleware, or including it in the window limiters (if it makes more sense).
fiber.Ctx
should be interface
(for customize)fiber.Error
's message should be interface
(for multiple error messages)fiber.App
Listen()
--> Start()
ListenTLS()
--> StartTLS()
fiber.Ctx
Query()
--> QueryParam()
Param()
--> PathParam()
Get()
--> GetReqHeader()
// GetRequestHeader()
Set()
--> SetReqHeader()
// SetRequestHeader()
Scheme()
--> returns http
or https
/ Protocol()
--> returns HTTP/1.1
or HTTP/2.0
(for HTTP2)Get()
--> GET()
, Post()
--> POST()
... )HTTP/2.0
SupportSupport gRPC (gRPC Gateway)
New Router Idea instead of Group
, Mount
and Route
func main() {
app := fiber.New()
app.Use("/user", UserRouter)
app.Listen(":3000")
}
func UserRouter() *fiber.Router {
router := fiber.NewRouter(fiber.RouterConfig{})
router.Get("/",func(c *fiber.Ctx) error {
return c.JSON("hi user")
})
return router
}
Here you can create the feature request for your ideas https://github.com/gofiber/fiber/milestone/1
Preferably one report per feature or if they go in the same direction, then also grouped together. And please provide a code example for the usage in the report(not the implementation).
We will then review them and decide which ones will make it into the core and start with the implementation.
You are also welcome to help us
In the next time we will create a beta branch, which will be used for development.
Suggest:
Suggest:
Login User
is a very common pattern when build a web app. I think web developers never say no to this feature.
Enable by default security best practices when protecting against common attacks that an API server could receive.
Enable by default security best practices when protecting against common attacks that an API server could receive.
Good idea, can you create a feature request for this
Maybe with a list of best practices which we should apply, so that it is clearly defined and you can start with the implementation.
Enable by default security best practices when protecting against common attacks that an API server could receive.
Good idea, can you create a feature request for this. Maybe with a list of best practices which we should apply, so that it is clearly defined and you can start with the implementation.
@ReneWerner87 I'll look into it when I get back from vacation (next week) and do a feature request with its implementation.
Features I'm thinking might go with v3
FEATURE 1: Include some features in gofiber client?
- Timeout
- Retry mechanism
- Throttle
FEATURE 2: I think implementing global template layout also a good idea (including option to add properties to template. For e.g.
app := fiber.New(fiber.Config { ... Template: html.NewFileSystem(...), TemplateLayout: "layouts/main", }) // Some fiber middleware to add properties to template app.Use(func (c *fiber.Ctx) error { c.LayoutProperty("auth", "blabla") return c.Next() }) // At this point, fiber would auto load view on above mentioned layout including all the properties from middleware // It would work like it's currently working if user provide layout as 3rd param // The properties would be available throughout the view file and layout app.Get("/login", fiber(c *fiber.Ctx) error { return c.Render("views/login") }
I would like to add retry mechanism. It seems that nobody has been started to implement it. If you accept to add this feature to v3, I can start to implement.
Features I'm thinking might go with v3 FEATURE 1: Include some features in gofiber client?
- Timeout
- Retry mechanism
- Throttle
FEATURE 2: I think implementing global template layout also a good idea (including option to add properties to template. For e.g.
app := fiber.New(fiber.Config { ... Template: html.NewFileSystem(...), TemplateLayout: "layouts/main", }) // Some fiber middleware to add properties to template app.Use(func (c *fiber.Ctx) error { c.LayoutProperty("auth", "blabla") return c.Next() }) // At this point, fiber would auto load view on above mentioned layout including all the properties from middleware // It would work like it's currently working if user provide layout as 3rd param // The properties would be available throughout the view file and layout app.Get("/login", fiber(c *fiber.Ctx) error { return c.Render("views/login") }
I would like to add retry mechanism. It seems that nobody has been started to implement it. If you accept to add this feature to v3, I can start to implement.
Sounds good, can you first create a feature report for it
unfortunately we have currently a little start issues
we first have to create the base for the start -> when this is done we will inform in the feature reports, so you can start then
Add built-in type references for func(c *fiber.CTX) error
called Route
for clarity.
Open issues for new suggestions/features about v3.
I want to be able to generate API interface documents automatically.
You can use go-swagger to generate swagger.json
. Then, just use openapi-typescript-codegen
in your front-end.
After that just add this script:
// package.json
"scripts": {
"gen:types": "openapi --input http://host:port/openapi.json --output ./src/generated --client axios --indent 2 --useOptions",
}
You can change the params, refer docs for more information. It will generate types and a client you can consume via tanstack-query or server components.
Dear Gophers, we think it's a good idea to start discussions regarding the v3. You are welcome to join us on discord where we created a dedicated channel to pin suggestions for the next update .