Skip to content

Commit

Permalink
Add debug list endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jveski committed Aug 13, 2023
1 parent 9e9975b commit 030d803
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sync/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sync

import (
"context"
"encoding/json"
"fmt"
"log"
"net/http"
Expand Down Expand Up @@ -44,6 +45,18 @@ func NewController(c *conf.Env, cli *client.Client) *Controller {
}

func (c *Controller) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Provide a super secret debug endpoint for listing the current cards
if r.URL.Path == "/cards" {
log.Printf("received list cards request")
cards, err := c.controller.ListCards(r.Context())
if err != nil {
http.Error(w, err.Error(), 500)
return
}
json.NewEncoder(w).Encode(&cards)
return
}

if !strings.HasPrefix(r.URL.Path, "/webhook") {
return
}
Expand Down

0 comments on commit 030d803

Please sign in to comment.