diff --git a/main.go b/main.go index dc51771..c4558ff 100644 --- a/main.go +++ b/main.go @@ -96,6 +96,7 @@ func main() { http.HandleFunc("/njump/image/", generate) http.HandleFunc("/njump/proxy/", proxy) http.Handle("/njump/static/", http.StripPrefix("/njump/", http.FileServer(http.FS(static)))) + http.HandleFunc("/services/oembed", renderOEmbed) http.HandleFunc("/npubs-archive/", renderArchive) http.HandleFunc("/relays-archive/", renderArchive) http.HandleFunc("/npubs-archive.xml", renderArchive) diff --git a/oembed.go b/oembed.go new file mode 100644 index 0000000..f39a56e --- /dev/null +++ b/oembed.go @@ -0,0 +1,21 @@ +package main + +import ( + "encoding/json" + "encoding/xml" + "net/http" +) + +func renderOEmbed(w http.ResponseWriter, r *http.Request) { + // target := r.URL.Query().Get("url") + data := 1 + + format := r.URL.Query().Get("format") + if format == "xml" { + w.Header().Add("Content-Type", "text/xml") + xml.NewEncoder(w).Encode(data) + } else { + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + } +}