iris/_examples/convert-handlers/nethttp/main.go
kataras 42b123975c 8.4.0 | New MVC Features | Refactor examples and godoc for go 1.9 use. Read HISTORY.md.
Former-commit-id: 90c05e743052bc3722e7fefaa0cbb0ed5153a1fb
2017-08-27 20:35:23 +03:00

35 lines
718 B
Go

package main
import (
"net/http"
"github.com/kataras/iris"
)
func main() {
app := iris.New()
ionMiddleware := iris.FromStd(nativeTestMiddleware)
app.Use(ionMiddleware)
// Method GET: http://localhost:8080/
app.Get("/", func(ctx iris.Context) {
ctx.HTML("Home")
})
// Method GET: http://localhost:8080/ok
app.Get("/ok", func(ctx iris.Context) {
ctx.HTML("<b>Hello world!</b>")
})
// http://localhost:8080
// http://localhost:8080/ok
app.Run(iris.Addr(":8080"))
}
func nativeTestMiddleware(w http.ResponseWriter, r *http.Request) {
println("Request path: " + r.URL.Path)
}
// Look "routing/custom-context" if you want to convert a custom handler with a custom Context
// to a context.Handler.