feat: go example
This commit is contained in:
1 parent
152510b3af
commit
69acc7ece9
7 files changed
+263
No files matched your search
+27
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/memstore"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/janishutz/oidclogin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := gin.Default()
|
||||
|
||||
// TODO: Better secret
|
||||
store := memstore.NewStore([]byte("secret"))
|
||||
r.Use(sessions.Sessions("jhid", store))
|
||||
|
||||
oidclogin.Configure(r, os.Getenv("APP_BASE_URL"), "/account", false)
|
||||
r.LoadHTMLGlob("public/*")
|
||||
|
||||
r.GET("/account", oidclogin.EnsureLogin(false), func(ctx *gin.Context) {
|
||||
ctx.HTML(200, "main.tmpl", gin.H{})
|
||||
})
|
||||
|
||||
r.Run()
|
||||
}
|
||||
Reference in new issue
Block a user