@ -61,6 +61,7 @@ var handler = map[string]localAPIHandler{
"component-debug-logging" : ( * Handler ) . serveComponentDebugLogging ,
"component-debug-logging" : ( * Handler ) . serveComponentDebugLogging ,
"debug" : ( * Handler ) . serveDebug ,
"debug" : ( * Handler ) . serveDebug ,
"derpmap" : ( * Handler ) . serveDERPMap ,
"derpmap" : ( * Handler ) . serveDERPMap ,
"dev-set-state-store" : ( * Handler ) . serveDevSetStateStore ,
"dial" : ( * Handler ) . serveDial ,
"dial" : ( * Handler ) . serveDial ,
"file-targets" : ( * Handler ) . serveFileTargets ,
"file-targets" : ( * Handler ) . serveFileTargets ,
"goroutines" : ( * Handler ) . serveGoroutines ,
"goroutines" : ( * Handler ) . serveGoroutines ,
@ -401,6 +402,23 @@ func (h *Handler) serveDebug(w http.ResponseWriter, r *http.Request) {
io . WriteString ( w , "done\n" )
io . WriteString ( w , "done\n" )
}
}
func ( h * Handler ) serveDevSetStateStore ( w http . ResponseWriter , r * http . Request ) {
if ! h . PermitWrite {
http . Error ( w , "debug access denied" , http . StatusForbidden )
return
}
if r . Method != "POST" {
http . Error ( w , "POST required" , http . StatusMethodNotAllowed )
return
}
if err := h . b . SetDevStateStore ( r . FormValue ( "key" ) , r . FormValue ( "value" ) ) ; err != nil {
http . Error ( w , err . Error ( ) , 500 )
return
}
w . Header ( ) . Set ( "Content-Type" , "text/plain" )
io . WriteString ( w , "done\n" )
}
func ( h * Handler ) serveComponentDebugLogging ( w http . ResponseWriter , r * http . Request ) {
func ( h * Handler ) serveComponentDebugLogging ( w http . ResponseWriter , r * http . Request ) {
if ! h . PermitWrite {
if ! h . PermitWrite {
http . Error ( w , "debug access denied" , http . StatusForbidden )
http . Error ( w , "debug access denied" , http . StatusForbidden )