Skip to content

Commit

Permalink
feat(server/config): 添加配置项
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Dec 3, 2024
1 parent 4601d86 commit b5dbc44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions server/config/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ type (
// 格式与 [http.Server.Addr] 相同。可以为空,表示由 [http.Server] 确定其默认值。
Port string `yaml:"port,omitempty" json:"port,omitempty" xml:"port,attr,omitempty"`

// [web.Router.URL] 的默认前缀
//
// 如果是非标准端口,应该带上端口号。
//
// NOTE: 每个路由可使用 [web.WithURLDomain] 重新定义该值。
URL string `yaml:"url,omitempty" json:"url,omitempty" xml:"url,omitempty"`

// x-request-id 的报头名称
//
// 如果为空,则采用 [header.XRequestID] 作为默认值。
Expand Down Expand Up @@ -262,6 +269,10 @@ func (h *httpConfig) buildInit(l *logs.Logs) {
if h.trace != nil {
o.RoutersOptions = append(o.RoutersOptions, h.trace)
}

if h.URL != "" {
o.RoutersOptions = append(o.RoutersOptions, web.WithURLDomain(h.URL))
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion web.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

// Version 当前框架的版本
const Version = "0.100.0"
const Version = "0.100.1"

type (
Logger = logs.Logger
Expand Down

0 comments on commit b5dbc44

Please sign in to comment.