🐛 bug: make Render bind parameter type any again (#3270)

* 🐛 bug: make Render bind parameter type any again

* update  docs
pull/3273/head
M. Efe Çetin 2025-01-02 10:42:25 +03:00 committed by GitHub
parent d5771a34df
commit 5355869d4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 5 deletions

2
ctx.go
View File

@ -1369,7 +1369,7 @@ func (c *DefaultCtx) GetRouteURL(routeName string, params Map) (string, error) {
// Render a template with data and sends a text/html response.
// We support the following engines: https://github.com/gofiber/template
func (c *DefaultCtx) Render(name string, bind Map, layouts ...string) error {
func (c *DefaultCtx) Render(name string, bind any, layouts ...string) error {
// Get new buffer from pool
buf := bytebufferpool.Get()
defer bytebufferpool.Put(buf)

View File

@ -12,8 +12,7 @@ import (
"github.com/valyala/fasthttp"
)
// Ctx represents the Context which hold the HTTP request and response.
// It has methods for the request query string, parameters, body, HTTP headers and so on.
// 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.
type Ctx interface {
// Accepts checks if the specified extensions or content types are acceptable.
Accepts(offers ...string) string
@ -263,7 +262,7 @@ type Ctx interface {
GetRouteURL(routeName string, params Map) (string, error)
// Render a template with data and sends a text/html response.
// We support the following engines: https://github.com/gofiber/template
Render(name string, bind Map, layouts ...string) error
Render(name string, bind any, layouts ...string) error
renderExtensions(bind any)
// Route returns the matched Route struct.
Route() *Route

View File

@ -1506,7 +1506,7 @@ app.Get("/teapot", func(c fiber.Ctx) error {
Renders a view with data and sends a `text/html` response. By default, `Render` uses the default [**Go Template engine**](https://pkg.go.dev/html/template/). If you want to use another view engine, please take a look at our [**Template middleware**](https://docs.gofiber.io/template).
```go title="Signature"
func (c fiber.Ctx) Render(name string, bind Map, layouts ...string) error
func (c fiber.Ctx) Render(name string, bind any, layouts ...string) error
```
## Request