Enhance API path normalization and configuration validation
- Introduced a new function to normalize request URL paths, collapsing duplicate slashes and clearing raw paths to ensure correct routing in the reverse proxy. - Updated the gateway to utilize the normalization function for API requests, improving routing consistency. - Trimmed whitespace from server configuration fields in the validation process to prevent potential issues with malformed URLs. - Enhanced documentation in GATEWAY_RUN.md to clarify the importance of proper URL formatting and configuration.
This commit is contained in:
@@ -75,6 +75,10 @@ func (c *Config) Validate() error {
|
||||
seen := make(map[string]struct{})
|
||||
for i := range c.Servers {
|
||||
s := &c.Servers[i]
|
||||
s.Alias = strings.TrimSpace(s.Alias)
|
||||
s.BaseURL = strings.TrimSpace(s.BaseURL)
|
||||
s.PathPrefix = strings.TrimSpace(s.PathPrefix)
|
||||
s.AuthorizationEnv = strings.TrimSpace(s.AuthorizationEnv)
|
||||
if s.Alias == "" {
|
||||
return fmt.Errorf("servers[%d]: alias is required", i)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user