mirror of
https://github.com/hacdias/webdav.git
synced 2026-09-26 21:21:54 +08:00
fix: pass through linters
License: MIT Signed-off-by: Henrique Dias <[email protected]>
This commit is contained in:
+2
-4
@@ -130,10 +130,8 @@ func parseCors(raw []interface{}, c *webdav.Config) {
|
||||
AllowedHosts: []string{},
|
||||
}
|
||||
|
||||
if allowed_hosts, ok := cfg["allowed_hosts"]; ok {
|
||||
for _, host := range strings.Split(allowed_hosts.(string), ",") {
|
||||
hosts = append(hosts, host)
|
||||
}
|
||||
if allowedHosts, ok := cfg["allowed_hosts"]; ok {
|
||||
hosts = append(hosts, strings.Split(allowedHosts.(string), ",")...)
|
||||
}
|
||||
|
||||
if len(hosts) == 0 {
|
||||
|
||||
+4
-4
@@ -6,13 +6,13 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Config is the configuration of a WebDAV instance.
|
||||
|
||||
// CorsCfg is the CORS config.
|
||||
type CorsCfg struct {
|
||||
Enabled bool
|
||||
AllowedHosts []string
|
||||
}
|
||||
|
||||
// Config is the configuration of a WebDAV instance.
|
||||
type Config struct {
|
||||
*User
|
||||
Auth bool
|
||||
@@ -30,11 +30,11 @@ func (c *Config) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
headers := w.Header()
|
||||
|
||||
if(len(c.Cors.AllowedHosts) == 1 && c.Cors.AllowedHosts[0] == "*") {
|
||||
if len(c.Cors.AllowedHosts) == 1 && c.Cors.AllowedHosts[0] == "*" {
|
||||
headers.Set("Access-Control-Allow-Methods", "*")
|
||||
headers.Set("Access-Control-Allow-Headers", "*")
|
||||
headers.Set("Access-Control-Allow-Origin", "*")
|
||||
} else if(isAllowedHost(c.Cors.AllowedHosts, requestOrigin)) {
|
||||
} else if isAllowedHost(c.Cors.AllowedHosts, requestOrigin) {
|
||||
headers.Set("Access-Control-Allow-Origin", requestOrigin)
|
||||
headers.Set("Access-Control-Allow-Headers", "*")
|
||||
headers.Set("Access-Control-Allow-Methods", "*")
|
||||
|
||||
Reference in New Issue
Block a user