2013-12-02 01:37:36 -08:00
|
|
|
package weed_server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2014-10-26 11:34:55 -07:00
|
|
|
|
2016-06-02 18:09:14 -07:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/stats"
|
2013-12-02 01:37:36 -08:00
|
|
|
)
|
|
|
|
|
2015-02-25 23:59:07 -08:00
|
|
|
/*
|
2013-12-02 01:37:36 -08:00
|
|
|
|
2015-03-09 01:10:01 -07:00
|
|
|
If volume server is started with a separated public port, the public port will
|
|
|
|
be more "secure".
|
|
|
|
|
|
|
|
Public port currently only supports reads.
|
|
|
|
|
|
|
|
Later writes on public port can have one of the 3
|
2015-02-25 23:59:07 -08:00
|
|
|
security settings:
|
|
|
|
1. not secured
|
|
|
|
2. secured by white list
|
|
|
|
3. secured by JWT(Json Web Token)
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
func (vs *VolumeServer) privateStoreHandler(w http.ResponseWriter, r *http.Request) {
|
2013-12-02 01:37:36 -08:00
|
|
|
switch r.Method {
|
2018-07-23 01:27:10 +08:00
|
|
|
case "GET", "HEAD":
|
2014-03-25 13:46:59 -07:00
|
|
|
stats.ReadRequest()
|
2014-05-26 21:15:05 -07:00
|
|
|
vs.GetOrHeadHandler(w, r)
|
2013-12-02 01:37:36 -08:00
|
|
|
case "DELETE":
|
2014-03-25 13:46:59 -07:00
|
|
|
stats.DeleteRequest()
|
2015-02-25 23:59:07 -08:00
|
|
|
vs.guard.WhiteList(vs.DeleteHandler)(w, r)
|
2018-07-23 01:27:10 +08:00
|
|
|
case "PUT", "POST":
|
2014-03-25 13:46:59 -07:00
|
|
|
stats.WriteRequest()
|
2015-02-25 23:59:07 -08:00
|
|
|
vs.guard.WhiteList(vs.PostHandler)(w, r)
|
2013-12-02 01:37:36 -08:00
|
|
|
}
|
|
|
|
}
|
2014-04-14 00:13:18 -07:00
|
|
|
|
2015-03-09 01:10:01 -07:00
|
|
|
func (vs *VolumeServer) publicReadOnlyHandler(w http.ResponseWriter, r *http.Request) {
|
2015-02-25 23:59:07 -08:00
|
|
|
switch r.Method {
|
|
|
|
case "GET":
|
|
|
|
stats.ReadRequest()
|
|
|
|
vs.GetOrHeadHandler(w, r)
|
|
|
|
case "HEAD":
|
|
|
|
stats.ReadRequest()
|
|
|
|
vs.GetOrHeadHandler(w, r)
|
2014-04-14 01:00:09 -07:00
|
|
|
}
|
|
|
|
}
|