mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 13:05:46 +00:00
Added basic handler placeholder and route in testcontrol
Signed-off-by: Simeng He <simeng@tailscale.com>
This commit is contained in:
parent
a321c24667
commit
f631128868
@ -99,6 +99,7 @@ func (s *Server) initMux() {
|
||||
s.mux.HandleFunc("/", s.serveUnhandled)
|
||||
s.mux.HandleFunc("/key", s.serveKey)
|
||||
s.mux.HandleFunc("/machine/", s.serveMachine)
|
||||
s.mux.HandleFunc("/ping", s.servePingInfo)
|
||||
}
|
||||
|
||||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
@ -172,6 +173,19 @@ func (s *Server) serveMachine(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// servePingInfo currently placeholder, determine the correct response to client
|
||||
func (s *Server) servePingInfo(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
if r.Method != "PUT" {
|
||||
http.Error(w, "Only PUT requests are supported currently", http.StatusMethodNotAllowed)
|
||||
}
|
||||
_, err := ioutil.ReadAll(r.Body)
|
||||
defer r.Body.Close()
|
||||
if err != nil {
|
||||
http.Error(w, "Failed to read request body", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
// Node returns the node for nodeKey. It's always nil or cloned memory.
|
||||
func (s *Server) Node(nodeKey tailcfg.NodeKey) *tailcfg.Node {
|
||||
s.mu.Lock()
|
||||
|
Loading…
Reference in New Issue
Block a user