httpshandler.go 422 B

12345678910111213141516171819202122
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/unrolled/secure"
  5. "gogs.baozhida.cn/zoie/OAuth-core/sdk/config"
  6. )
  7. func TlsHandler() gin.HandlerFunc {
  8. return func(c *gin.Context) {
  9. secureMiddleware := secure.New(secure.Options{
  10. SSLRedirect: true,
  11. SSLHost: config.SslConfig.Domain,
  12. })
  13. err := secureMiddleware.Process(c.Writer, c.Request)
  14. if err != nil {
  15. return
  16. }
  17. c.Next()
  18. }
  19. }