mirror of
https://github.com/photoprism/photoprism.git
synced 2025-11-02 21:14:05 +08:00
32 lines
753 B
Go
32 lines
753 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/photoprism/photoprism/internal/api"
|
|
"github.com/photoprism/photoprism/internal/context"
|
|
)
|
|
|
|
func registerRoutes(router *gin.Engine, ctx *context.Context) {
|
|
// Favicon
|
|
router.StaticFile("/favicon.ico", ctx.HttpFaviconsPath()+"/favicon.ico")
|
|
|
|
// Static assets like js and css files
|
|
router.Static("/assets", ctx.HttpPublicPath())
|
|
|
|
// JSON-REST API Version 1
|
|
v1 := router.Group("/api/v1")
|
|
{
|
|
api.GetPhotos(v1, ctx)
|
|
api.GetThumbnail(v1, ctx)
|
|
api.LikePhoto(v1, ctx)
|
|
api.DislikePhoto(v1, ctx)
|
|
}
|
|
|
|
// Default HTML page (client-side routing implemented via Vue.js)
|
|
router.NoRoute(func(c *gin.Context) {
|
|
c.HTML(http.StatusOK, "index.tmpl", ctx.ClientConfig())
|
|
})
|
|
}
|