-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (29 loc) · 761 Bytes
/
main.go
File metadata and controls
36 lines (29 loc) · 761 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
34
35
36
// +build go.1.8
package main
import (
"github.com/get-ion/ion"
"github.com/get-ion/ion/context"
)
func main() {
app := ion.Default()
// Method: GET
// Resource: http://localhost:8080/
app.Handle("GET", "/", func(ctx context.Context) {
ctx.HTML("<b>Hello world!</b>")
})
// same as app.Handle("GET", "/ping", [...])
// Method: GET
// Resource: http://context:8080/ping
app.Get("/ping", func(ctx context.Context) {
ctx.WriteString("pong")
})
// Method: GET
// Resource: http://localhost:8080/hello
app.Get("/hello", func(ctx context.Context) {
ctx.JSON(context.Map{"message": "Hello ion web framework."})
})
// http://localhost:8080
// http://localhost:8080/ping
// http://localhost:8080/hello
app.Run(ion.Addr(":8080"))
}