-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmain.go
More file actions
33 lines (25 loc) · 769 Bytes
/
main.go
File metadata and controls
33 lines (25 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"net/http"
"gopkg.in/kataras/iris.v6"
"gopkg.in/kataras/iris.v6/adaptors/httprouter"
)
func main() {
app := iris.New()
// output startup banner and error logs on os.Stdout
app.Adapt(iris.DevLogger())
// set the router, you can choose gorillamux too
app.Adapt(httprouter.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())
})
// call .Boot before use the 'app' as an http.Handler on a custom http.Server
app.Boot()
// create our custom fasthttp server and assign the Handler/Router
fsrv := &http.Server{Handler: app, Addr: ":8080"}
fsrv.ListenAndServe()
// navigate to http://127.0.0.1:8080/mypath
}