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-03 18:57:28 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/context"
|
2018-09-13 07:05:13 +02:00
|
|
|
)
|
|
|
|
|
2019-05-04 13:29:32 +02:00
|
|
|
func registerRoutes(router *gin.Engine, ctx *context.Context) {
|
2018-12-21 04:05:14 +01:00
|
|
|
// Favicon
|
2019-05-04 13:29:32 +02:00
|
|
|
router.StaticFile("/favicon.ico", ctx.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-04 13:29:32 +02:00
|
|
|
router.Static("/assets", ctx.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-03 18:57:28 +02:00
|
|
|
api.GetPhotos(v1, ctx)
|
|
|
|
api.GetThumbnail(v1, ctx)
|
|
|
|
api.LikePhoto(v1, ctx)
|
|
|
|
api.DislikePhoto(v1, ctx)
|
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-03 18:57:28 +02:00
|
|
|
c.HTML(http.StatusOK, "index.tmpl", ctx.ClientConfig())
|
2018-09-13 07:05:13 +02:00
|
|
|
})
|
|
|
|
}
|