mirror of
https://github.com/photoprism/photoprism.git
synced 2025-10-17 06:11:00 +08:00
Server: Handle HEAD requests #2965
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -13,9 +13,10 @@ import (
|
||||
// registerStaticRoutes configures serving static assets and templates.
|
||||
func registerStaticRoutes(router *gin.Engine, conf *config.Config) {
|
||||
// Redirects to the PWA for now, can be replaced by a template later.
|
||||
router.GET(conf.BaseUri("/"), func(c *gin.Context) {
|
||||
login := func(c *gin.Context) {
|
||||
c.Redirect(http.StatusTemporaryRedirect, conf.LoginUri())
|
||||
})
|
||||
}
|
||||
router.Any(conf.BaseUri("/"), login)
|
||||
|
||||
// Shows "Page Not found" error if no other handler is registered.
|
||||
router.NoRoute(func(c *gin.Context) {
|
||||
@@ -34,31 +35,34 @@ func registerStaticRoutes(router *gin.Engine, conf *config.Config) {
|
||||
})
|
||||
|
||||
// Loads Progressive Web App (PWA) on all routes beginning with "library".
|
||||
router.GET(conf.BaseUri("/library/*path"), func(c *gin.Context) {
|
||||
pwa := func(c *gin.Context) {
|
||||
values := gin.H{
|
||||
"signUp": gin.H{"message": config.MsgSponsor, "url": config.SignUpURL},
|
||||
"config": conf.ClientPublic(),
|
||||
}
|
||||
c.HTML(http.StatusOK, conf.TemplateName(), values)
|
||||
})
|
||||
}
|
||||
router.Any(conf.BaseUri("/library/*path"), pwa)
|
||||
|
||||
// Progressive Web App (PWA) Manifest.
|
||||
router.GET(conf.BaseUri("/manifest.json"), func(c *gin.Context) {
|
||||
manifest := func(c *gin.Context) {
|
||||
c.Header("Cache-Control", "no-store")
|
||||
c.Header("Content-Type", "application/json")
|
||||
|
||||
clientConfig := conf.ClientPublic()
|
||||
c.HTML(http.StatusOK, "manifest.json", gin.H{"config": clientConfig})
|
||||
})
|
||||
}
|
||||
router.Any(conf.BaseUri("/manifest.json"), manifest)
|
||||
|
||||
// Progressive Web App (PWA) Service Worker.
|
||||
swWorker := func(c *gin.Context) {
|
||||
c.Header("Cache-Control", "no-store")
|
||||
c.File(filepath.Join(conf.BuildPath(), "sw.js"))
|
||||
}
|
||||
router.GET("/sw.js", swWorker)
|
||||
router.Any("/sw.js", swWorker)
|
||||
|
||||
if swUri := conf.BaseUri("/sw.js"); swUri != "/sw.js" {
|
||||
router.GET(swUri, swWorker)
|
||||
router.Any(swUri, swWorker)
|
||||
}
|
||||
|
||||
// Serves static favicon.
|
||||
|
Reference in New Issue
Block a user