MCPcopy Create free account
hub / github.com/eventure/hide.client.linux / route

Method route

control/methods.go:61–75  ·  view source on GitHub ↗
( writer http.ResponseWriter, request *http.Request )

Source from the content-addressed store, hash-verified

59}
60
61func ( s *Server ) route( writer http.ResponseWriter, request *http.Request ) {
62 if request.Method != "GET" { http.Error( writer, http.StatusText( http.StatusNotFound ), http.StatusNotFound ); return }
63 select {
64 case s.connectionOpsLock<-struct{}{}: defer func() { <-s.connectionOpsLock }(); break
65 case <-time.NewTimer( time.Second ).C: http.Error( writer, http.StatusText( http.StatusConflict ), http.StatusConflict ); return
66 }
67
68 switch code := s.connection.Code(); code {
69 case connection.Clean:
70 if err := s.connection.Init(); err != nil { writer.Write( Result{ Error: &Error{ Code: CodeRoute, Message: err.Error() } }.Json() ); return }
71 writer.Write( Result{ Result: s.connection.State() }.Json() )
72 default:
73 writer.Write( Result{ Error: &Error{ Code: CodeRoute, Message: "bad state: " + code } }.Json() )
74 }
75}
76
77func ( s *Server ) connect( writer http.ResponseWriter, request *http.Request ) {
78 if request.Method != "GET" { http.Error( writer, http.StatusText( http.StatusNotFound ), http.StatusNotFound ); return }

Callers

nothing calls this directly

Calls 6

CodeMethod · 0.80
WriteMethod · 0.80
JsonMethod · 0.80
StateMethod · 0.80
ErrorMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected