Compare commits

..

2 Commits

Author SHA1 Message Date
Piotr Biernat
f49b420e78 Merge branch 'develop' into develop-config 2021-07-09 18:34:21 +02:00
Piotr Biernat
0675fc61d5 Base config support 2021-07-09 18:30:18 +02:00
5 changed files with 52 additions and 0 deletions

17
config/config.go Normal file
View File

@ -0,0 +1,17 @@
package config
type Config struct {
Server Server
Services map[string]Service
}
type Server struct {
Address string
Port int
}
type Service struct {
BaseURL string
ForwardTo string
Protocol string
}

18
config/test/sample.json Normal file
View File

@ -0,0 +1,18 @@
{
"server": {
"address": "127.0.0.1",
"port": 8080
},
"services": {
"test-app1": {
"baseUrl": "test/",
"forwardTo": "127.0.0.1:3030/",
"protocol": "http"
},
"test-app2": {
"baseUrl": "test2/",
"forwardTo": "httpbin.org/",
"protocol": "http"
}
}
}

2
go.mod
View File

@ -1,3 +1,5 @@
module vegvisir module vegvisir
go 1.13 go 1.13
require github.com/opentracing/opentracing-go v1.2.0 // indirect

View File

@ -9,5 +9,11 @@ package main
// Copyright (c) 2021 Piotr Biernat. https://pbiernat.dev. MIT License // Copyright (c) 2021 Piotr Biernat. https://pbiernat.dev. MIT License
// Repo: https://git.pbiernat.dev/golang/vegvisir // Repo: https://git.pbiernat.dev/golang/vegvisir
import (
"vegvisir/server"
)
func main() { func main() {
s := server.NewServer()
err := s.LoadConfig("config/test/sample.json")
} }

View File

@ -1,5 +1,14 @@
package server package server
// ___ ____ ___ ___
// \ \ / / | _ | __| \ \ / / || | __ || || _ |
// \ \/ / |___ | |__ \ \/ / || |___ || ||___|
// \ / | _ | _ | \ / || __ | || ||\\
// \/ |___ |___ | \/ || ____| || || \\
// Copyright (c) 2021 Piotr Biernat. https://pbiernat.dev. MIT License
// Repo: https://git.pbiernat.dev/golang/vegvisir
import ( import (
"encoding/json" "encoding/json"
"io/ioutil" "io/ioutil"