| 7 | ) |
| 8 | |
| 9 | func main() { |
| 10 | app := iris.New() |
| 11 | |
| 12 | app.Get("/", func(ctx iris.Context) { |
| 13 | ctx.Writef("Hello from the server") |
| 14 | }) |
| 15 | |
| 16 | app.Get("/mypath", func(ctx iris.Context) { |
| 17 | ctx.Writef("Hello from %s", ctx.Path()) |
| 18 | }) |
| 19 | |
| 20 | // Any custom fields here. Handler and ErrorLog are set to the server automatically |
| 21 | srv := &http.Server{Addr: ":8080"} |
| 22 | |
| 23 | // http://localhost:8080/ |
| 24 | // http://localhost:8080/mypath |
| 25 | app.Run(iris.Server(srv)) // same as app.Listen(":8080") |
| 26 | |
| 27 | // More: |
| 28 | // see "multi" if you need to use more than one server at the same app. |
| 29 | // |
| 30 | // for a custom listener use: iris.Listener(net.Listener) or |
| 31 | // iris.TLS(cert,key) or iris.AutoTLS(), see "custom-listener" example for those. |
| 32 | } |