Files
mp-qvyun/backend/providers/http/config.go
2024-11-28 23:18:11 +08:00

46 lines
673 B
Go

package http
import (
"fmt"
)
const DefaultPrefix = "Http"
type Config struct {
StaticPath *string
StaticRoute *string
Host *string
Port uint
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 == nil {
return h.PortString()
}
return fmt.Sprintf("%s:%d", *h.Host, h.Port)
}
func (h *Config) PortString() string {
return fmt.Sprintf(":%d", h.Port)
}