Fix syndication support
parent
da07e28de1
commit
c00f934658
10
micropub.go
10
micropub.go
|
@ -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()))
|
||||||
|
|
Loading…
Reference in New Issue