| 118 | } |
| 119 | |
| 120 | func ( s *Server ) shutdown( writer http.ResponseWriter, request *http.Request ) { |
| 121 | if request.Method != "GET" { http.Error( writer, http.StatusText( http.StatusNotFound ), http.StatusNotFound ); return } |
| 122 | select { |
| 123 | case s.connectionOpsLock<-struct{}{}: defer func() { <-s.connectionOpsLock }(); break |
| 124 | case <-time.NewTimer( time.Second ).C: http.Error( writer, http.StatusText( http.StatusConflict ), http.StatusConflict ); return |
| 125 | } |
| 126 | writer.Header().Add( "content-type", "application/json" ) |
| 127 | s.connection.Shutdown() |
| 128 | writer.Write( Result{ Result: s.connection.State() }.Json() ) |
| 129 | } |
| 130 | |
| 131 | // destroy is harsh, disconnects and removes everything set up by Init() |
| 132 | func ( s *Server ) destroy( writer http.ResponseWriter, request *http.Request ) { |