custom port
This commit is contained in:
parent
e1c8698be3
commit
af16831100
15
config.toml
15
config.toml
@ -1,19 +1,26 @@
|
||||
[TH7]
|
||||
port = 8080
|
||||
port = 9090
|
||||
logfreq = 60
|
||||
|
||||
[DB]
|
||||
type = "sqlite3"
|
||||
path = "test.db"
|
||||
|
||||
[Channel_1]
|
||||
type = 'J'
|
||||
|
||||
[Channel_2]
|
||||
type = 'N'
|
||||
unit = 'C'
|
||||
|
||||
[Channel_3]
|
||||
type = 'T'
|
||||
unit = 'C'
|
||||
|
||||
[Channel_4]
|
||||
type = 'K'
|
||||
unit = 'C'
|
||||
|
||||
[Channel_6]
|
||||
type = 'J'
|
||||
unit = 'C'
|
||||
offset = -23.1
|
||||
|
||||
|
||||
|
2
main.go
2
main.go
@ -53,7 +53,7 @@ func main() {
|
||||
}
|
||||
defer dbPort.Close()
|
||||
|
||||
webPort = web.NewGinAdapter(corePort)
|
||||
webPort = web.NewGinAdapter(corePort, config.Board.Port)
|
||||
go webPort.Run()
|
||||
|
||||
sig := <-kill
|
||||
|
@ -1,6 +1,7 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@ -12,6 +13,7 @@ import (
|
||||
type GinAdapter struct {
|
||||
router *gin.Engine
|
||||
corePort ports.CorePort
|
||||
port int
|
||||
}
|
||||
|
||||
func (g GinAdapter) registerEndpoints() {
|
||||
@ -49,10 +51,11 @@ func (g GinAdapter) registerEndpoints() {
|
||||
|
||||
}
|
||||
|
||||
func NewGinAdapter(corePort ports.CorePort) *GinAdapter {
|
||||
func NewGinAdapter(corePort ports.CorePort, port int) *GinAdapter {
|
||||
var adapter GinAdapter
|
||||
|
||||
adapter.corePort = corePort
|
||||
adapter.port = port
|
||||
|
||||
adapter.router = gin.Default()
|
||||
adapter.registerEndpoints()
|
||||
@ -61,5 +64,6 @@ func NewGinAdapter(corePort ports.CorePort) *GinAdapter {
|
||||
}
|
||||
|
||||
func (g *GinAdapter) Run() {
|
||||
g.router.Run()
|
||||
portStr := fmt.Sprintf(":%d", g.port)
|
||||
g.router.Run(portStr)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user