fix(dashboard): correctly fail in createEmbed
matching `nil != nil` doesn't work, no clue what this code was supposed to do
This commit is contained in:
parent
9303dbb91e
commit
528da39e66
@ -84,7 +84,7 @@ func notFoundHandler(rw http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// explanation for createEmbed:
|
// explanation for createEmbed:
|
||||||
// we don't care about errors, we just want to return a HTML page as soon as possible
|
// we don't care about errors, we just want to return a HTML page as soon as possible
|
||||||
// `panic(nil)` is caught by upstream, which then returns the raw HTML page
|
// `panic(1)` is caught by upstream, which then returns the raw HTML page
|
||||||
|
|
||||||
func createEmbed(rw http.ResponseWriter, r *http.Request) {
|
func createEmbed(rw http.ResponseWriter, r *http.Request) {
|
||||||
entityType := chi.URLParam(r, "type")
|
entityType := chi.URLParam(r, "type")
|
||||||
@ -100,22 +100,22 @@ func createEmbed(rw http.ResponseWriter, r *http.Request) {
|
|||||||
case "g":
|
case "g":
|
||||||
path = "/groups/" + id
|
path = "/groups/" + id
|
||||||
default:
|
default:
|
||||||
panic(nil)
|
panic(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := http.Get(baseURL + path)
|
res, err := http.Get(baseURL + path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(nil)
|
panic(1)
|
||||||
}
|
}
|
||||||
if res.StatusCode != 200 {
|
if res.StatusCode != 200 {
|
||||||
panic(nil)
|
panic(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
var data entity
|
var data entity
|
||||||
body, _ := io.ReadAll(res.Body)
|
body, _ := io.ReadAll(res.Body)
|
||||||
err = json.Unmarshal(body, &data)
|
err = json.Unmarshal(body, &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(nil)
|
panic(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
text := fmt.Sprintf(`<link type="application/json+oembed" href="%s/%s/oembed.json" />%s`, baseURL, path, "\n")
|
text := fmt.Sprintf(`<link type="application/json+oembed" href="%s/%s/oembed.json" />%s`, baseURL, path, "\n")
|
||||||
@ -136,7 +136,7 @@ func createEmbed(rw http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
html, err := fs.ReadFile("dist/index.html")
|
html, err := fs.ReadFile("dist/index.html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(nil)
|
panic(1)
|
||||||
}
|
}
|
||||||
html = []byte(strings.Replace(string(html), `<!-- extra data -->`, text+versionJS, 1))
|
html = []byte(strings.Replace(string(html), `<!-- extra data -->`, text+versionJS, 1))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user