Fix syndication support

kcoram/uplift
Jan-Lukas Else 2019-12-22 14:11:59 +01:00
parent da07e28de1
commit c00f934658
1 changed files with 8 additions and 2 deletions

View File

@ -7,13 +7,19 @@ import (
"time" "time"
) )
type MicropubConfig struct {
SyndicateTo []SyndicationTarget `json:"syndicate-to,omitempty"`
}
func HandleMicroPub(w http.ResponseWriter, r *http.Request) { func HandleMicroPub(w http.ResponseWriter, r *http.Request) {
// a handler for GET requests, used for troubleshooting // a handler for GET requests, used for troubleshooting
if r.Method == "GET" { 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.Header().Add("Content-type", "application/json")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
jsonBytes, err := json.Marshal(SyndicationTargets) jsonBytes, err := json.Marshal(&MicropubConfig{
SyndicateTo: SyndicationTargets,
})
if err != nil { if err != nil {
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
_, _ = w.Write([]byte(err.Error())) _, _ = w.Write([]byte(err.Error()))