This commit is contained in:
2025-12-15 17:55:32 +08:00
commit 28ab17324d
170 changed files with 18373 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package http
import (
"fmt"
)
const DefaultPrefix = "Http"
type Config struct {
Host string
Port uint
StaticPath *string
StaticRoute *string
BaseURI *string
Tls *Tls
Cors *Cors
}
type Tls struct {
Cert string
Key string
}
type Cors struct {
Mode string
Whitelist []Whitelist
}
type Whitelist struct {
AllowOrigin string
AllowHeaders string
AllowMethods string
ExposeHeaders string
AllowCredentials bool
}
func (h *Config) Address() string {
if h.Host == "" {
return fmt.Sprintf("0.0.0.0:%d", h.Port)
}
return fmt.Sprintf("%s:%d", h.Host, h.Port)
}