From c00f934658f486ff37de6724a341dd57c10f9f09 Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Sun, 22 Dec 2019 14:11:59 +0100 Subject: [PATCH] Fix syndication support --- micropub.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/micropub.go b/micropub.go index ff3a85e..afe4efc 100644 --- a/micropub.go +++ b/micropub.go @@ -7,13 +7,19 @@ import ( "time" ) +type MicropubConfig struct { + SyndicateTo []SyndicationTarget `json:"syndicate-to,omitempty"` +} + func HandleMicroPub(w http.ResponseWriter, r *http.Request) { // a handler for GET requests, used for troubleshooting if r.Method == "GET" { - if q := r.URL.Query().Get("q"); q == "syndicate-to" { + if q := r.URL.Query().Get("q"); q == "config" || q == "syndicate-to" { w.Header().Add("Content-type", "application/json") w.WriteHeader(http.StatusOK) - jsonBytes, err := json.Marshal(SyndicationTargets) + jsonBytes, err := json.Marshal(&MicropubConfig{ + SyndicateTo: SyndicationTargets, + }) if err != nil { w.WriteHeader(http.StatusBadRequest) _, _ = w.Write([]byte(err.Error()))