mirror of
https://github.com/kataras/iris.git
synced 2025-12-22 20:37:05 +00:00
Nothing special here, just split the static handler to a package-level func and per-route func (same as before)
Former-commit-id: 1912d85de84856c715dfa7b79d771cada1b638b9
This commit is contained in:
@@ -55,39 +55,5 @@ func main() {
|
||||
|
||||
})
|
||||
|
||||
// ------ first customization without even the need of *Context or a Handler--------
|
||||
//
|
||||
// Custom new content-/type:
|
||||
// app.Adapt(iris.RenderPolicy(func(out io.Writer, name string, binding interface{}, options ...map[string]interface{}) (error, bool) {
|
||||
// if name == "customcontent-type" {
|
||||
//
|
||||
// // some very advanced things here:
|
||||
// out.Write([]byte(binding.(string)))
|
||||
// return nil, true
|
||||
// }
|
||||
// return nil, false
|
||||
// }))
|
||||
//
|
||||
// app.Get("/custom", func(ctx *iris.Context) {
|
||||
// ctx.RenderWithStatus(iris.StatusOK, // or MustRender
|
||||
// "customcontent-type",
|
||||
// "my custom content here!",
|
||||
// )
|
||||
// })
|
||||
//
|
||||
// ---- second -----------------------------------------------------------------------
|
||||
//
|
||||
// Override the defaults (the json,xml,jsonp,text,data and so on), an existing content-type:
|
||||
// app.Adapt(iris.RenderPolicy(func(out io.Writer, name string, binding interface{}, options ...map[string]interface{}) (error, bool) {
|
||||
// if name == "text/plain" {
|
||||
// out.Write([]byte("From the custom text/plain renderer: " + binding.(string)))
|
||||
// return nil, true
|
||||
// }
|
||||
//
|
||||
// return nil, false
|
||||
// }))
|
||||
// // the context.Text's behaviors was changed now by your custom renderer.
|
||||
//
|
||||
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user