forked from go-admin-team/go-admin-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat[Https]: added https support (go-admin-team#113)
- Loading branch information
1 parent
5d69b32
commit 0177fb1
Showing
9 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package handler | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/unrolled/secure" | ||
"go-admin/tools/config" | ||
) | ||
|
||
func TlsHandler() gin.HandlerFunc { | ||
return func(c *gin.Context) { | ||
secureMiddleware := secure.New(secure.Options{ | ||
SSLRedirect: true, | ||
SSLHost: config.ApplicationConfig.Domain, | ||
}) | ||
err := secureMiddleware.Process(c.Writer, c.Request) | ||
if err != nil { | ||
return | ||
} | ||
c.Next() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package config | ||
|
||
import "github.com/spf13/viper" | ||
|
||
type Ssl struct { | ||
KeyStr string | ||
Pem string | ||
} | ||
|
||
func InitSsl(cfg *viper.Viper) *Ssl { | ||
return &Ssl{ | ||
KeyStr: cfg.GetString("key"), | ||
Pem: cfg.GetString("pem"), | ||
} | ||
} | ||
|
||
var SslConfig = new(Ssl) |