custom port

This commit is contained in:
William Clark 2022-12-05 14:25:48 +00:00
parent e1c8698be3
commit af16831100
3 changed files with 18 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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)
}