Monorepo for Tangled tangled.org

appview/state: support /favicon.ico #1015

open opened by boltless.me targeting master from sl/wznxxmtqvxwk

apps like pdsls.dev expects favicon to exist in well-known path

Signed-off-by: Seongmin Lee git@boltless.me

Labels

None yet.

assignee

None yet.

Participants 3
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3mda56w3xqo22
+3 -1
Interdiff #0 β†’ #1
+3 -1
appview/state/router.go
··· 32 32 s.pages, 33 33 ) 34 34 35 - router.Get("/favicon.ico", func(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/static/logos/dolly.ico", http.StatusMovedPermanently) }) 35 + router.Get("/favicon.ico", func(w http.ResponseWriter, r *http.Request) { 36 + http.Redirect(w, r, "/static/logos/dolly.ico", http.StatusMovedPermanently) 37 + }) 36 38 router.Get("/pwa-manifest.json", s.WebAppManifest) 37 39 router.Get("/robots.txt", s.RobotsTxt) 38 40

History

3 rounds 7 comments
sign up or login to add to the discussion
1 commit
expand
appview/state: support /favicon.ico
3/3 success
expand
no conflicts, ready to merge
expand 2 comments

hm, we already have page.Static, why an other handler? can we use the existing http handler and just give it a file path?

router.Get("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
    r2 := r.Clone(r.Context())
    r2.URL.Path = "/static/logos/dolly.ico"
    s.pages.Static().ServeHTTP(w, r2)
})

maybe something like that?

I think it is better not to nest the http handlers like that. pages.StaticFile pattern can be easily used for other routes like:

	router.Get("/favicon.ico", s.pages.StaticFile("logos/dolly.ico").ServeHTTP)
	router.Get("/pwa-manifest.json", s.pages.StaticFile("manifest.webmanifest").ServeHTTP)
	router.Get("/robots.txt", s.pages.StaticFile("robots.txt").ServeHTTP)
	// ...
1 commit
expand
appview/state: support /favicon.ico
3/3 success
expand
expand 4 comments

Does it have to be a redirect? Can’t we simply serve the same file here?

oh wait, it was using redirect too, my bad.

perhaps we should include favicon.svg as well!

1 commit
expand
appview/state: support /favicon.ico
1/3 failed, 2/3 success
expand
expand 1 comment

lgtm barring CI!