Skip to content

Commit

Permalink
api: return host list, not struct
Browse files Browse the repository at this point in the history
We should use the dispatcher set interface rather than encoding the
structs directly.

Fixes #6

Signed-off-by: Seán C McCord <ulexus@gmail.com>
  • Loading branch information
Ulexus committed May 18, 2020
1 parent 67395bf commit fb06813
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
)

func (s *dispatcherSets) startHTTP(ctx context.Context, addr string) {

http.HandleFunc("/check/", s.handleIPCheckRequest)
http.HandleFunc("/dispatcher/", s.handleListSetRequest)
http.HandleFunc("/dispatchers/", s.handleListSetRequest)
Expand Down Expand Up @@ -40,7 +39,6 @@ func (s *dispatcherSets) handleIPCheckRequest(w http.ResponseWriter, r *http.Req

w.WriteHeader(http.StatusNotFound)
return

}

// Return a given dispatcher set
Expand All @@ -62,7 +60,7 @@ func (s *dispatcherSets) handleListSetRequest(w http.ResponseWriter, r *http.Req
if selectedSet != nil {
w.Header().Add("Content-Type", "application/json")

if err = json.NewEncoder(w).Encode(selectedSet); err != nil {
if err = json.NewEncoder(w).Encode(selectedSet.Hosts()); err != nil {
w.WriteHeader(http.StatusInternalServerError)
}
return
Expand Down

0 comments on commit fb06813

Please sign in to comment.