responses

This commit is contained in:
Andre Medeiros 2021-10-13 15:11:27 -04:00
parent 08fd2ef9a5
commit 7714046de2

View file

@ -28,6 +28,10 @@ type createWatcherRequest struct {
Criteria watcherCriteria Criteria watcherCriteria
} }
type watcherCreatedResponse struct {
ID int64 `json:"id"`
}
func (a *api) createWatcherHandler(w http.ResponseWriter, r *http.Request) { func (a *api) createWatcherHandler(w http.ResponseWriter, r *http.Request) {
ctx := context.Background() ctx := context.Background()
@ -144,6 +148,8 @@ func (a *api) createWatcherHandler(w http.ResponseWriter, r *http.Request) {
} }
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(watcherCreatedResponse{ID: watcher.ID})
} }
func (a *api) editWatcherHandler(w http.ResponseWriter, r *http.Request) { func (a *api) editWatcherHandler(w http.ResponseWriter, r *http.Request) {
@ -208,15 +214,15 @@ func (a *api) deleteWatcherHandler(w http.ResponseWriter, r *http.Request) {
} }
type watcherItem struct { type watcherItem struct {
ID int64 ID int64 `json:"id"`
CreatedAt float64 CreatedAt float64 `json:"created_at"`
Type string Type string `json:"type"`
Label string Label string `json:"label"`
Upvotes int64 Upvotes int64 `json:"upvotes"`
Keyword string Keyword string `json:"keyword"`
Flair string Flair string `json:"flair"`
Domain string Domain string `json:"domain"`
Hits int64 Hits int64 `json:"hits"`
} }
func (a *api) listWatchersHandler(w http.ResponseWriter, r *http.Request) { func (a *api) listWatchersHandler(w http.ResponseWriter, r *http.Request) {