photoprism/internal/server/routes.go
2018-12-21 04:05:14 +01:00

31 lines
750 B
Go

package server
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/photoprism/photoprism/internal/api"
"github.com/photoprism/photoprism/internal/photoprism"
)
func registerRoutes(app *gin.Engine, conf photoprism.Config) {
// Favicon
app.StaticFile("/favicon.ico", conf.HttpFaviconsPath()+"/favicon.ico")
// Static assets like js and css files
app.Static("/assets", conf.HttpPublicPath())
// JSON-REST API Version 1
v1 := app.Group("/api/v1")
{
api.GetPhotos(v1, conf)
api.GetThumbnail(v1, conf)
api.LikePhoto(v1, conf)
api.DislikePhoto(v1, conf)
}
// Default HTML page (client-side routing implemented via Vue.js)
app.NoRoute(func(c *gin.Context) {
c.HTML(http.StatusOK, "index.tmpl", conf.ClientConfig())
})
}