2018-09-13 07:05:13 +02:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
2018-09-17 18:40:57 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/photoprism"
|
2018-09-24 11:27:46 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/routes"
|
2018-09-13 07:05:13 +02:00
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2018-09-24 11:27:46 +02:00
|
|
|
func registerRoutes(app *gin.Engine, conf *photoprism.Config) {
|
|
|
|
// Favicon images
|
2018-09-18 23:24:19 +02:00
|
|
|
app.StaticFile("/favicon.ico", conf.GetFaviconsPath()+"/favicon.ico")
|
|
|
|
app.StaticFile("/favicon.png", conf.GetFaviconsPath()+"/favicon.png")
|
2018-09-13 11:34:56 +02:00
|
|
|
|
2018-09-24 11:27:46 +02:00
|
|
|
// Static assets like js and css files
|
2018-09-18 23:24:19 +02:00
|
|
|
app.Static("/assets", conf.GetPublicPath())
|
2018-09-13 07:05:13 +02:00
|
|
|
|
|
|
|
// JSON-REST API Version 1
|
|
|
|
v1 := app.Group("/api/v1")
|
|
|
|
{
|
2018-09-24 11:27:46 +02:00
|
|
|
routes.GetPhotos(v1, conf)
|
|
|
|
routes.GetThumbnail(v1, conf)
|
2018-09-13 07:05:13 +02:00
|
|
|
}
|
|
|
|
|
2018-09-24 11:27:46 +02:00
|
|
|
// Default HTML page (client-side routing implemented via Vue.js)
|
2018-09-13 07:05:13 +02:00
|
|
|
app.NoRoute(func(c *gin.Context) {
|
2018-09-13 10:23:06 +02:00
|
|
|
c.HTML(http.StatusOK, "index.tmpl", conf.GetClientConfig())
|
2018-09-13 07:05:13 +02:00
|
|
|
})
|
|
|
|
}
|