2018-09-13 07:05:13 +02:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2018-10-31 07:14:33 +01:00
|
|
|
"net/http"
|
|
|
|
|
2018-09-13 07:05:13 +02:00
|
|
|
"github.com/gin-gonic/gin"
|
2018-09-24 21:14:15 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/api"
|
2018-09-17 18:40:57 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/photoprism"
|
2018-09-13 07:05:13 +02:00
|
|
|
)
|
|
|
|
|
2018-11-17 06:21:39 +01:00
|
|
|
func registerRoutes(app *gin.Engine, conf photoprism.Config) {
|
2018-09-24 11:27:46 +02:00
|
|
|
// 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 21:14:15 +02:00
|
|
|
api.GetPhotos(v1, conf)
|
|
|
|
api.GetThumbnail(v1, conf)
|
2018-10-31 03:33:18 +01:00
|
|
|
api.LikePhoto(v1, conf)
|
|
|
|
api.DislikePhoto(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
|
|
|
})
|
|
|
|
}
|