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"
|
2019-05-06 23:18:10 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/config"
|
2018-09-13 07:05:13 +02:00
|
|
|
)
|
|
|
|
|
2019-05-06 23:18:10 +02:00
|
|
|
func registerRoutes(router *gin.Engine, conf *config.Config) {
|
2018-12-21 04:05:14 +01:00
|
|
|
// Favicon
|
2019-05-06 23:18:10 +02:00
|
|
|
router.StaticFile("/favicon.ico", conf.HttpFaviconsPath()+"/favicon.ico")
|
2018-09-13 11:34:56 +02:00
|
|
|
|
2018-09-24 11:27:46 +02:00
|
|
|
// Static assets like js and css files
|
2019-05-06 23:18:10 +02:00
|
|
|
router.Static("/assets", conf.HttpPublicPath())
|
2018-09-13 07:05:13 +02:00
|
|
|
|
|
|
|
// JSON-REST API Version 1
|
2019-05-04 13:29:32 +02:00
|
|
|
v1 := router.Group("/api/v1")
|
2018-09-13 07:05:13 +02:00
|
|
|
{
|
2019-05-06 23:18:10 +02:00
|
|
|
api.GetPhotos(v1, conf)
|
|
|
|
api.GetThumbnail(v1, conf)
|
|
|
|
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)
|
2019-05-04 13:29:32 +02:00
|
|
|
router.NoRoute(func(c *gin.Context) {
|
2019-05-06 23:18:10 +02:00
|
|
|
c.HTML(http.StatusOK, "index.tmpl", conf.ClientConfig())
|
2018-09-13 07:05:13 +02:00
|
|
|
})
|
|
|
|
}
|