mirror of
https://github.com/kataras/iris.git
synced 2025-12-23 21:07:03 +00:00
Add fallback handlers
Former-commit-id: f7e9bd17076a10e1ed1702780d7ce9e89f00b592
This commit is contained in:
@@ -5,6 +5,7 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/core/router"
|
||||
|
||||
"github.com/iris-contrib/middleware/cors"
|
||||
)
|
||||
@@ -14,6 +15,7 @@ func main() {
|
||||
app := iris.New()
|
||||
crs := cors.New(cors.Options{
|
||||
AllowedOrigins: []string{"*"}, // allows everything, use that to change the hosts.
|
||||
AllowedMethods: router.AllMethods[:],
|
||||
AllowCredentials: true,
|
||||
})
|
||||
|
||||
@@ -29,6 +31,12 @@ func main() {
|
||||
v1.Post("/send", func(ctx iris.Context) {
|
||||
ctx.WriteString("sent")
|
||||
})
|
||||
v1.Put("/send", func(ctx iris.Context) {
|
||||
ctx.WriteString("updated")
|
||||
})
|
||||
v1.Delete("/send", func(ctx iris.Context) {
|
||||
ctx.WriteString("deleted")
|
||||
})
|
||||
}
|
||||
|
||||
// or use that to wrap the entire router
|
||||
|
||||
Reference in New Issue
Block a user