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-22 13:55:11 +02:00
|
|
|
router.Static("/static", conf.HttpStaticPath())
|
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-11-08 06:53:40 +01:00
|
|
|
api.CreateSession(v1, conf)
|
|
|
|
api.DeleteSession(v1, conf)
|
|
|
|
|
2019-12-11 14:10:20 +01:00
|
|
|
api.GetPreview(v1, conf)
|
2019-05-06 23:18:10 +02:00
|
|
|
api.GetThumbnail(v1, conf)
|
2019-05-14 18:16:35 +02:00
|
|
|
api.GetDownload(v1, conf)
|
2019-12-05 19:21:35 +01:00
|
|
|
api.CreateZip(v1, conf)
|
|
|
|
api.DownloadZip(v1, conf)
|
2019-06-09 04:37:02 +02:00
|
|
|
|
2019-12-11 19:11:44 +01:00
|
|
|
api.GetPhoto(v1, conf)
|
|
|
|
api.UpdatePhoto(v1, conf)
|
2019-06-09 04:37:02 +02:00
|
|
|
api.GetPhotos(v1, conf)
|
2019-12-05 21:06:53 +01:00
|
|
|
api.GetPhotoDownload(v1, conf)
|
2019-05-06 23:18:10 +02:00
|
|
|
api.LikePhoto(v1, conf)
|
|
|
|
api.DislikePhoto(v1, conf)
|
2019-06-09 04:37:02 +02:00
|
|
|
|
|
|
|
api.GetLabels(v1, conf)
|
|
|
|
api.LikeLabel(v1, conf)
|
|
|
|
api.DislikeLabel(v1, conf)
|
|
|
|
api.LabelThumbnail(v1, conf)
|
2019-06-13 20:26:01 +02:00
|
|
|
|
|
|
|
api.Upload(v1, conf)
|
2020-01-02 03:57:28 +01:00
|
|
|
api.StartImport(v1, conf)
|
|
|
|
api.CancelImport(v1, conf)
|
2020-01-02 02:58:26 +01:00
|
|
|
api.StartIndexing(v1, conf)
|
|
|
|
api.CancelIndexing(v1, conf)
|
2019-06-15 01:35:18 +02:00
|
|
|
|
|
|
|
api.BatchPhotosDelete(v1, conf)
|
2019-06-15 03:44:10 +02:00
|
|
|
api.BatchPhotosPrivate(v1, conf)
|
2019-06-18 07:28:30 +02:00
|
|
|
api.BatchPhotosStory(v1, conf)
|
2019-12-06 16:47:30 +01:00
|
|
|
api.BatchAlbumsDelete(v1, conf)
|
2019-06-17 21:45:06 +02:00
|
|
|
|
2019-12-05 14:11:45 +01:00
|
|
|
api.GetAlbum(v1, conf)
|
2019-12-06 11:56:24 +01:00
|
|
|
api.CreateAlbum(v1, conf)
|
|
|
|
api.UpdateAlbum(v1, conf)
|
|
|
|
api.DeleteAlbum(v1, conf)
|
2019-12-06 16:47:30 +01:00
|
|
|
api.DownloadAlbum(v1, conf)
|
2019-06-17 21:45:06 +02:00
|
|
|
api.GetAlbums(v1, conf)
|
|
|
|
api.LikeAlbum(v1, conf)
|
|
|
|
api.DislikeAlbum(v1, conf)
|
|
|
|
api.AlbumThumbnail(v1, conf)
|
2019-12-05 12:10:30 +01:00
|
|
|
api.AddPhotosToAlbum(v1, conf)
|
|
|
|
api.RemovePhotosFromAlbum(v1, conf)
|
2019-11-12 04:34:37 +01:00
|
|
|
|
|
|
|
api.GetSettings(v1, conf)
|
|
|
|
api.SaveSettings(v1, conf)
|
2019-11-16 16:06:34 +01:00
|
|
|
|
|
|
|
api.Websocket(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-11-17 06:21:43 +01:00
|
|
|
c.HTML(http.StatusOK, "index.tmpl", gin.H{"clientConfig": conf.ClientConfig()})
|
2018-09-13 07:05:13 +02:00
|
|
|
})
|
|
|
|
}
|