mirror of https://github.com/gofiber/fiber.git
Add Handler & Templates interface (#412)
* Add new supporter * Add new test condition * Add Handler Type * Update Templates Interfacepull/417/head
parent
e8b8fdfb35
commit
02b4061b44
4
app.go
4
app.go
|
@ -94,8 +94,8 @@ type Settings struct {
|
|||
// When set to true, it will not print out the fiber ASCII and "listening" on message
|
||||
DisableStartupMessage bool
|
||||
|
||||
// RenderEngine is the interface that wraps the Render function.
|
||||
RenderEngine RenderEngine
|
||||
// Templates is the interface that wraps the Render function.
|
||||
Templates Templates
|
||||
|
||||
// The amount of time allowed to read the full request including body.
|
||||
ReadTimeout time.Duration // default: unlimited
|
||||
|
|
10
ctx.go
10
ctx.go
|
@ -65,8 +65,8 @@ type Cookie struct {
|
|||
SameSite string
|
||||
}
|
||||
|
||||
// RenderEngine is the interface that wraps the Render function.
|
||||
type RenderEngine interface {
|
||||
// Templates is the interface that wraps the Render function.
|
||||
type Templates interface {
|
||||
Render(io.Writer, string, interface{}) error
|
||||
}
|
||||
|
||||
|
@ -717,9 +717,9 @@ func (ctx *Ctx) Render(name string, bind interface{}) (err error) {
|
|||
defer bytebufferpool.Put(buf)
|
||||
|
||||
// Use ViewEngine if exist
|
||||
if ctx.app.Settings.RenderEngine != nil {
|
||||
// Render template with engine
|
||||
if err := ctx.app.Settings.RenderEngine.Render(buf, name, bind); err != nil {
|
||||
if ctx.app.Settings.Templates != nil {
|
||||
// Render template from ViewEngine
|
||||
if err := ctx.app.Settings.Templates.Render(buf, name, bind); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue