Files
authorizer/server/handlers/app.go

31 lines
732 B
Go
Raw Normal View History

2021-07-30 23:42:15 +05:30
package handlers
import (
"log"
"net/http"
"github.com/gin-gonic/gin"
)
// TODO read query param = state which is base64 encoded
// make sure url is present in allowed origins
// set that in redirect_url
func AppHandler() gin.HandlerFunc {
return func(c *gin.Context) {
log.Println("Host:", c.Request.Host)
// debug the request state
if pusher := c.Writer.Pusher(); pusher != nil {
// use pusher.Push() to do server push
if err := pusher.Push("/app/build/bundle.js", nil); err != nil {
log.Printf("Failed to push: %v", err)
}
}
c.HTML(http.StatusOK, "app.tmpl", gin.H{
"data": map[string]string{
2021-08-02 23:03:40 +05:30
"authorizerURL": c.Request.Host,
"redirect_url": "http://localhost:8080/app",
2021-07-30 23:42:15 +05:30
},
})
}
}