oembed initial work.

This commit is contained in:
fiatjaf
2023-09-23 15:43:06 -03:00
parent 14d4b961b8
commit 25a683e9c8
2 changed files with 22 additions and 0 deletions

View File

@@ -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)

21
oembed.go Normal file
View File

@@ -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)
}
}