feat: add OpenSearch XML endpoint
- Serve /opensearch.xml with configurable base URL - Browsers can now add gosearch as a search engine from the address bar - Configurable via [server] base_url or BASE_URL env var - XML template embedded in the binary via go:embed - Added base_url to config.example.toml
This commit is contained in:
parent
3caf702c4f
commit
4ec600f6c0
6 changed files with 51 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ type Config struct {
|
|||
type ServerConfig struct {
|
||||
Port int `toml:"port"`
|
||||
HTTPTimeout string `toml:"http_timeout"`
|
||||
BaseURL string `toml:"base_url"` // Public URL for OpenSearch XML (e.g. "https://search.example.com")
|
||||
}
|
||||
|
||||
type UpstreamConfig struct {
|
||||
|
|
@ -158,6 +159,9 @@ func applyEnvOverrides(cfg *Config) {
|
|||
if v := os.Getenv("RATE_LIMIT_CLEANUP_INTERVAL"); v != "" {
|
||||
cfg.RateLimit.CleanupInterval = v
|
||||
}
|
||||
if v := os.Getenv("BASE_URL"); v != "" {
|
||||
cfg.Server.BaseURL = v
|
||||
}
|
||||
}
|
||||
|
||||
// HTTPTimeout parses the configured timeout string into a time.Duration.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue