Skip to content

Commit

Permalink
support TLS
Browse files Browse the repository at this point in the history
  • Loading branch information
Clivern committed Mar 12, 2019
1 parent 53bf53f commit e03c857
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ app:
port: 8080
domain: example.com
secret: sWUhHRcs4Aqa0MEnYwbuQln3EW8CZ0oD
tls:
status: off
pemPath: cert/server.pem
keyPath: cert/server.key

log:
level: info
Expand Down Expand Up @@ -333,7 +337,7 @@ Socket("ws://localhost:8080/ws/$ID/$TOKEN");

[![Build Status](https://travis-ci.org/Clivern/Beaver.svg?branch=master)](https://travis-ci.org/Clivern/Beaver)
[![GitHub license](https://img.shields.io/github/license/Clivern/Beaver.svg)](https://github.com/Clivern/Beaver/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/Version-1.1.2-red.svg)](https://github.com/Clivern/Beaver/releases)
[![Version](https://img.shields.io/badge/Version-1.1.3-red.svg)](https://github.com/Clivern/Beaver/releases)
[![Go Report Card](https://goreportcard.com/badge/github.com/Clivern/Beaver)](https://goreportcard.com/report/github.com/Clivern/Beaver)

## For contributors
Expand Down Expand Up @@ -368,6 +372,11 @@ Then Create a PR with the master branch.

## Changelog

* Version 1.1.3:
```
Support TLS.
```

* Version 1.1.2:
```
Update Docs.
Expand Down
14 changes: 11 additions & 3 deletions beaver.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ func main() {
return
}

os.Setenv("PORT", strconv.Itoa(config.Get("app", "port").Int(8080)))

if config.Get("app", "mode").String("dev") == "prod" {
gin.SetMode(gin.ReleaseMode)
gin.DisableConsoleColor()
Expand Down Expand Up @@ -127,5 +125,15 @@ func main() {

go socket.HandleMessages()

r.Run()
if config.Get("app", "tls", "status").Bool(false) {
r.RunTLS(
fmt.Sprintf(":%s", strconv.Itoa(config.Get("app", "port").Int(8080))),
config.Get("app", "tls", "pemPath").String(""),
config.Get("app", "tls", "keyPath").String(""),
)
} else {
r.Run(
fmt.Sprintf(":%s", strconv.Itoa(config.Get("app", "port").Int(8080))),
)
}
}
4 changes: 4 additions & 0 deletions config.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ app:
port: 8080
domain: example.com
secret: sWUhHRcs4Aqa0MEnYwbuQln3EW8CZ0oD
tls:
status: off
pemPath: cert/server.pem
keyPath: cert/server.key

log:
level: info
Expand Down
4 changes: 4 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ app:
port: 8080
domain: example.com
secret: sWUhHRcs4Aqa0MEnYwbuQln3EW8CZ0oD
tls:
status: off
pemPath: cert/server.pem
keyPath: cert/server.key

log:
level: info
Expand Down

0 comments on commit e03c857

Please sign in to comment.