mirror of
https://github.com/aljazceru/njump.git
synced 2026-02-20 21:44:32 +01:00
oembed initial work.
This commit is contained in:
1
main.go
1
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)
|
||||
|
||||
21
oembed.go
Normal file
21
oembed.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user