summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSimeng He <simeng@tailscale.com>2021-06-02 13:54:13 -0400
committerSimeng He <simeng@tailscale.com>2021-06-02 13:54:13 -0400
commitf6311288683cd97e14f17e662ccf92f49b04595a (patch)
treebf8d3918a71eefb8fe26fd7e846f63038320d81a
parenta321c24667b9c5e93622e63aee2efceb583a3de0 (diff)
downloadtailscale-simenghe/add-httphandlers-ping.tar.xz
tailscale-simenghe/add-httphandlers-ping.zip
Added basic handler placeholder and route in testcontrolsimenghe/add-httphandlers-ping
Signed-off-by: Simeng He <simeng@tailscale.com>
-rw-r--r--tstest/integration/testcontrol/testcontrol.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/tstest/integration/testcontrol/testcontrol.go b/tstest/integration/testcontrol/testcontrol.go
index 4683cbc0b..434b6a311 100644
--- a/tstest/integration/testcontrol/testcontrol.go
+++ b/tstest/integration/testcontrol/testcontrol.go
@@ -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()