-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
main.go
34 lines (26 loc) · 763 Bytes
/
main.go
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
package main
import (
"time"
"github.com/kataras/iris/v12/_examples/dependency-injection/sessions/routes"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/sessions"
)
func main() {
app := iris.New()
sessionManager := sessions.New(sessions.Config{
Cookie: "site_session_id",
Expires: 60 * time.Minute,
AllowReclaim: true,
})
// Session is automatically binded through `sessions.Get(ctx)`
// if a *sessions.Session input argument is present on the handler's function,
// which `routes.Index` does.
app.Use(sessionManager.Handler())
// Method: GET
// Path: http://localhost:8080
app.ConfigureContainer(registerRoutes)
app.Listen(":8080")
}
func registerRoutes(api *iris.APIContainer) {
api.Get("/", routes.Index)
}