adjustment

This commit is contained in:
mr 2025-03-28 08:48:39 +01:00
parent d76473bb0f
commit e45f7c2bf8
7 changed files with 34 additions and 41 deletions

View File

@ -6,8 +6,13 @@ build: clean
run: run:
bee run -gendoc=true -downdoc=true bee run -gendoc=true -downdoc=true
dev: purge:
bee generate routers && HTTPPORT=8091 bee run -gendoc=true -downdoc=true lsof -t -i:8091 | xargs kill | true
run-dev:
bee generate routers && bee run -gendoc=true -downdoc=true -runmode=prod
dev: purge run-dev
debug: debug:
bee run -downdebug -gendebug bee run -downdebug -gendebug
@ -27,4 +32,4 @@ publish-registry:
all: docker publish-kind publish-registry all: docker publish-kind publish-registry
.PHONY: build run clean docker publish-kind publish-registry .PHONY: build run clean docker publish-kind publish-registry

View File

@ -15,7 +15,10 @@ type VersionController struct {
// @Success 200 // @Success 200
// @router / [get] // @router / [get]
func (c *VersionController) GetAll() { func (c *VersionController) GetAll() {
c.Data["json"] = map[string]string{"version": "1"} c.Data["json"] = map[string]string{
"service": "oc-shared",
"version": "1",
}
c.ServeJSON() c.ServeJSON()
} }

View File

@ -1,34 +0,0 @@
version: '3.4'
services:
mongo:
image: 'mongo:latest'
networks:
- catalog
ports:
- 27017:27017
container_name: mongo
volumes:
- oc-catalog-data:/data/db
- oc-catalog-data:/data/configdb
mongo-express:
image: "mongo-express:latest"
restart: always
depends_on:
- mongo
networks:
- catalog
ports:
- 8081:8081
environment:
- ME_CONFIG_BASICAUTH_USERNAME=test
- ME_CONFIG_BASICAUTH_PASSWORD=test
volumes:
oc-catalog-data:
networks:
catalog:
external: true
# name: catalog

View File

@ -18,8 +18,8 @@ services:
- "traefik.http.services.shared.loadbalancer.server.port=8080" - "traefik.http.services.shared.loadbalancer.server.port=8080"
- "traefik.http.middlewares.shared.forwardauth.address=http://oc-auth:8080/oc/forward" - "traefik.http.middlewares.shared.forwardauth.address=http://oc-auth:8080/oc/forward"
networks: networks:
- catalog - oc
networks: networks:
catalog: oc:
external: true external: true

19
main.go
View File

@ -11,8 +11,26 @@ import (
const appname = "oc-shared" const appname = "oc-shared"
func main() { func main() {
// Init the oc-lib
// Init the oc-lib // Init the oc-lib
oclib.Init(appname) oclib.Init(appname)
// Load the right config file
o := oclib.GetConfLoader()
// feed the library with the loaded config
oclib.SetConfig(
o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"),
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
o.GetStringDefault("NATS_URL", "nats://localhost:4222"),
o.GetStringDefault("LOKI_URL", ""),
o.GetStringDefault("LOG_LEVEL", "info"),
)
// Beego init
beego.BConfig.AppName = appname
beego.BConfig.Listen.HTTPPort = o.GetIntDefault("port", 8080)
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{ beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowAllOrigins: true, AllowAllOrigins: true,
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
@ -20,5 +38,6 @@ func main() {
ExposeHeaders: []string{"Content-Length", "Content-Type"}, ExposeHeaders: []string{"Content-Length", "Content-Type"},
AllowCredentials: true, AllowCredentials: true,
})) }))
beego.Run() beego.Run()
} }

BIN
oc-shared Executable file

Binary file not shown.

View File

@ -1,5 +1,5 @@
{ {
"port":8080, "port":8091,
"MONGO_URL":"mongodb://localhost:27017/", "MONGO_URL":"mongodb://localhost:27017/",
"MONGO_DATABASE":"DC_myDC" "MONGO_DATABASE":"DC_myDC"
} }