mirror of
https://github.com/pushbits/server.git
synced 2025-07-28 05:48:00 +02:00
Add support for configuration of TLS
This commit is contained in:
parent
833e666c37
commit
61d5e04ecf
8 changed files with 65 additions and 12 deletions
|
@ -5,14 +5,19 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pushbits/server/internal/configuration"
|
||||
)
|
||||
|
||||
// Run starts the Gin engine.
|
||||
func Run(engine *gin.Engine, address string, port int) error {
|
||||
err := engine.Run(fmt.Sprintf("%s:%d", address, port))
|
||||
if err != nil {
|
||||
return err
|
||||
func Run(engine *gin.Engine, c *configuration.Configuration) error {
|
||||
var err error
|
||||
address := fmt.Sprintf("%s:%d", c.HTTP.ListenAddress, c.HTTP.Port)
|
||||
|
||||
if c.HTTP.CertFile != "" && c.HTTP.KeyFile != "" {
|
||||
err = engine.RunTLS(address, c.HTTP.CertFile, c.HTTP.KeyFile)
|
||||
} else {
|
||||
err = engine.Run(address)
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue