HandleListSessions handles the `GET /sessions/` request and responds with a JSON formatted list of session names.
(c web.C, w http.ResponseWriter, r *http.Request)
| 150 | // HandleListSessions handles the `GET /sessions/` request and responds with a JSON formatted list |
| 151 | // of session names. |
| 152 | func (s *Server) HandleListSessions(c web.C, w http.ResponseWriter, r *http.Request) { |
| 153 | sessions, err := s.Store.List("/sessions/") |
| 154 | if err != nil { |
| 155 | http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) |
| 156 | return |
| 157 | } |
| 158 | |
| 159 | json.NewEncoder(w).Encode(struct { |
| 160 | Sessions []string `json:"sessions"` |
| 161 | }{Sessions: sessions}) |
| 162 | } |
| 163 | |
| 164 | // HandleGetSession handles the `GET /sessions/:id` request and responds with the session |
| 165 | // object in JSON format. |