forked from iris-contrib/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
31 lines (24 loc) · 808 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
// Package main provide one-line integration with letsencrypt.org
package main
import (
"github.com/kataras/iris"
"github.com/kataras/iris/context"
)
func main() {
app := iris.New()
app.Get("/", func(ctx context.Context) {
ctx.Writef("Hello from SECURE SERVER!")
})
app.Get("/test2", func(ctx context.Context) {
ctx.Writef("Welcome to secure server from /test2!")
})
app.Get("/redirect", func(ctx context.Context) {
ctx.Redirect("/test2")
})
// If http to https auto-redirect is one of your needs
// please look the code inside iris_deprecateed.go.ListenLETSENCRYPT to do it manually.
// NOTE: This may not work on local addresses like this,
// use it on a real domain, because
// it uses the "golang.org/x/crypto/acme/autocert" package.
app.Run(iris.AutoTLS("localhost:443"))
}