|
|
@ -1,10 +1,11 @@ |
|
|
|
package weed_server |
|
|
|
|
|
|
|
import ( |
|
|
|
"github.com/chrislusf/seaweedfs/weed/util" |
|
|
|
"net/http" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/util" |
|
|
|
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/glog" |
|
|
|
"github.com/chrislusf/seaweedfs/weed/security" |
|
|
|
"github.com/chrislusf/seaweedfs/weed/stats" |
|
|
@ -27,6 +28,10 @@ security settings: |
|
|
|
|
|
|
|
func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
w.Header().Set("Server", "SeaweedFS Volume "+util.VERSION) |
|
|
|
if r.Header.Get("Origin") != "" { |
|
|
|
w.Header().Set("Access-Control-Allow-Origin", "*") |
|
|
|
w.Header().Set("Access-Control-Allow-Credentials", "true") |
|
|
|
} |
|
|
|
switch r.Method { |
|
|
|
case "GET", "HEAD": |
|
|
|
stats.ReadRequest() |
|
|
@ -37,11 +42,18 @@ func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Reque |
|
|
|
case "PUT", "POST": |
|
|
|
stats.WriteRequest() |
|
|
|
vs.guard.WhiteList(vs.PostHandler)(w, r) |
|
|
|
case "OPTIONS": |
|
|
|
stats.ReadRequest() |
|
|
|
vs.guard.WhiteList(vs.OptionsHandler)(w, r) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func (vs *VolumeServer) publicReadOnlyHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
w.Header().Set("Server", "SeaweedFS Volume "+util.VERSION) |
|
|
|
if r.Header.Get("Origin") != "" { |
|
|
|
w.Header().Set("Access-Control-Allow-Origin", "*") |
|
|
|
w.Header().Set("Access-Control-Allow-Credentials", "true") |
|
|
|
} |
|
|
|
switch r.Method { |
|
|
|
case "GET": |
|
|
|
stats.ReadRequest() |
|
|
@ -49,6 +61,9 @@ func (vs *VolumeServer) publicReadOnlyHandler(w http.ResponseWriter, r *http.Req |
|
|
|
case "HEAD": |
|
|
|
stats.ReadRequest() |
|
|
|
vs.GetOrHeadHandler(w, r) |
|
|
|
case "OPTIONS": |
|
|
|
stats.ReadRequest() |
|
|
|
vs.OptionsHandler(w, r) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|