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
+1
Diff #0
+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 36 router.Get("/pwa-manifest.json", s.WebAppManifest) 36 37 router.Get("/robots.txt", s.RobotsTxt) 37 38

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
merge conflicts detected
expand
  • appview/state/router.go:32
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鈥檛 we simply serve the same file here?

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

perhaps we should include favicon.svg as well!

boltless.me submitted #0
1 commit
expand
appview/state: support /favicon.ico
1/3 failed, 2/3 success
expand
expand 1 comment

lgtm barring CI!