mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
ed45c77be5
Former-commit-id: ed635ee95de7160cde11eaabc0c1dcb0e460a620
33 lines
753 B
Go
33 lines
753 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/kataras/iris/v12"
|
|
)
|
|
|
|
func main() {
|
|
app := iris.New()
|
|
|
|
app.Get("/", func(ctx iris.Context) {
|
|
ctx.Writef("Hello from the server")
|
|
})
|
|
|
|
app.Get("/mypath", func(ctx iris.Context) {
|
|
ctx.Writef("Hello from %s", ctx.Path())
|
|
})
|
|
|
|
// Any custom fields here. Handler and ErrorLog are set to the server automatically
|
|
srv := &http.Server{Addr: ":8080"}
|
|
|
|
// http://localhost:8080/
|
|
// http://localhost:8080/mypath
|
|
app.Run(iris.Server(srv)) // same as app.Listen(":8080")
|
|
|
|
// More:
|
|
// see "multi" if you need to use more than one server at the same app.
|
|
//
|
|
// for a custom listener use: iris.Listener(net.Listener) or
|
|
// iris.TLS(cert,key) or iris.AutoTLS(), see "custom-listener" example for those.
|
|
}
|