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

Method token

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

Source from the content-addressed store, hash-verified

172}
173
174func ( s *Server ) token( writer http.ResponseWriter, request *http.Request ) {
175 select {
176 case s.connectionOpsLock<-struct{}{}: defer func() { <-s.connectionOpsLock }(); break
177 case <-time.NewTimer( time.Second ).C: http.Error( writer, http.StatusText( http.StatusConflict ), http.StatusConflict ); return
178 }
179 switch request.Method {
180 case "DELETE":
181 writer.Header().Add( "content-type", "application/json" )
182 s.connection.Lock(); defer s.connection.Unlock()
183 writer.Write( Result{ Result: os.Remove( s.connection.Config.Rest.AccessTokenPath ) }.Json() )
184 case "GET":
185 writer.Header().Add( "content-type", "application/json" )
186 switch accessToken, err := s.connection.AccessTokenFetch(); err {
187 case nil: writer.Write( Result{ Result: accessToken }.Json() )
188 default: writer.Write( Result{ Error: &Error{ Code: CodeToken, Message: err.Error() } }.Json())
189 }
190 default:
191 http.Error( writer, http.StatusText( http.StatusNotFound ), http.StatusNotFound ); return
192 }
193 return
194}
195
196func ( s *Server ) log( writer http.ResponseWriter, request *http.Request ) {
197 logs := []byte( nil )

Callers

nothing calls this directly

Calls 4

WriteMethod · 0.80
JsonMethod · 0.80
AccessTokenFetchMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected