update routes

This commit is contained in:
2026-05-16 11:10:36 +07:00
parent f1c69c0f1f
commit f23a0c2152
7 changed files with 64 additions and 39 deletions
+19 -6
View File
@@ -7,7 +7,8 @@ import (
)
const (
ClientPort = ":8100"
GrpcGatewayPort = ":8090"
UserClientPort = ":8100"
AdminClientPort = ":8110"
FilePort = ":8120"
)
@@ -20,7 +21,19 @@ func GetDBFilepath() string {
return getFilepath("DB_FILENAME", "data/db/store.db")
}
func GetAdminHost() string {
func GetGrpcGatewayHost() string {
host := os.Getenv("HOST")
if host != "" {
return host
}
ips, err := getLocalIPs()
if err != nil || len(ips) == 0 {
return "http://127.0.0.1" + GrpcGatewayPort
}
return "http://" + ips[0] + GrpcGatewayPort
}
func GetAdminClientHost() string {
host := os.Getenv("HOST")
if host != "" {
return host
@@ -32,20 +45,20 @@ func GetAdminHost() string {
return "http://" + ips[0] + AdminClientPort
}
func GetHost() string {
func GetUserClientHost() string {
host := os.Getenv("HOST")
if host != "" {
return host
}
ips, err := getLocalIPs()
if err != nil || len(ips) == 0 {
return "http://127.0.0.1" + ClientPort
return "http://127.0.0.1" + UserClientPort
}
return "http://" + ips[0] + ClientPort
return "http://" + ips[0] + UserClientPort
}
func GetFileHost() string {
host := os.Getenv("FILE_HOST")
host := os.Getenv("HOST")
if host != "" {
return host
}
+1 -1
View File
@@ -19,7 +19,7 @@ func NewDBService(filepath string) (IDBService, error) {
if err != nil {
return nil, err
}
log.Printf("load db from: %s", filepath)
log.Printf("Load db from: %s", filepath)
_, err = db.Exec("CREATE TABLE IF NOT EXISTS teams (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE NOT NULL CHECK(length(trim(name)) > 0), password TEXT);")
if err != nil {
return nil, err
@@ -25,7 +25,7 @@ func (s *fileService) Load(ctx context.Context) (*models.Story, error) {
if err != nil {
return nil, fmt.Errorf("story file %s not found", s.filepath)
}
log.Printf("load story from: %s", s.filepath)
log.Printf("Load story from: %s", s.filepath)
story := &models.Story{}
if err := json.Unmarshal(data, story); err != nil {
return nil, err