jlelse
/
hugo-micropub
Archived
1
Fork 0

Fix syndication support

This commit is contained in:
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"
)
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()))