destroy is harsh, disconnects and removes everything set up by Init()
( writer http.ResponseWriter, request *http.Request )
| 130 | |
| 131 | // destroy is harsh, disconnects and removes everything set up by Init() |
| 132 | func ( s *Server ) destroy( writer http.ResponseWriter, request *http.Request ) { |
| 133 | if request.Method != "GET" { http.Error( writer, http.StatusText( http.StatusNotFound ), http.StatusNotFound ); return } |
| 134 | select { |
| 135 | case s.connectionOpsLock<-struct{}{}: defer func() { <-s.connectionOpsLock }(); break |
| 136 | case <-time.NewTimer( time.Second ).C: http.Error( writer, http.StatusText( http.StatusConflict ), http.StatusConflict ); return |
| 137 | } |
| 138 | |
| 139 | writer.Header().Add( "content-type", "application/json" ) |
| 140 | s.connection.Disconnect() |
| 141 | s.connection.Shutdown() |
| 142 | writer.Write( Result{ Result: s.connection.State() }.Json() ) |
| 143 | } |
| 144 | |
| 145 | func ( s *Server ) state( writer http.ResponseWriter, request *http.Request ) { |
| 146 | if request.Method != "GET" { http.Error( writer, http.StatusText( http.StatusNotFound ), http.StatusNotFound ); return } |