2018-09-13 07:05:13 +02:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
2022-07-05 23:13:34 +02:00
|
|
|
|
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
|
|
|
)
|
|
|
|
|
2022-10-18 14:21:23 +02:00
|
|
|
// registerRoutes configures the available web server routes.
|
2019-05-06 23:18:10 +02:00
|
|
|
func registerRoutes(router *gin.Engine, conf *config.Config) {
|
2022-01-05 11:40:44 +01:00
|
|
|
// Enables automatic redirection if the current route cannot be matched but a
|
2021-01-02 18:56:15 +01:00
|
|
|
// handler for the path with (without) the trailing slash exists.
|
|
|
|
router.RedirectTrailingSlash = true
|
|
|
|
|
2022-10-18 14:21:23 +02:00
|
|
|
// Static assets and templates.
|
|
|
|
registerStaticRoutes(router, conf)
|
2022-09-02 19:09:25 +02:00
|
|
|
|
2022-10-18 14:21:23 +02:00
|
|
|
// Built-in WebDAV server.
|
|
|
|
registerWebDAVRoutes(router, conf)
|
2018-09-13 07:05:13 +02:00
|
|
|
|
2022-10-18 14:21:23 +02:00
|
|
|
// Sharing routes start with "/s".
|
|
|
|
registerSharingRoutes(router, conf)
|
2022-05-27 18:15:18 +02:00
|
|
|
|
2018-09-13 07:05:13 +02:00
|
|
|
// JSON-REST API Version 1
|
2021-07-05 16:41:43 +02:00
|
|
|
v1 := router.Group(conf.BaseUri(config.ApiUri))
|
2018-09-13 07:05:13 +02:00
|
|
|
{
|
2022-10-17 19:07:38 +02:00
|
|
|
// Authentication.
|
|
|
|
api.CreateSession(v1)
|
|
|
|
api.GetSession(v1)
|
|
|
|
api.DeleteSession(v1)
|
|
|
|
|
|
|
|
// Global Config.
|
2020-12-18 20:42:12 +01:00
|
|
|
api.GetConfigOptions(v1)
|
|
|
|
api.SaveConfigOptions(v1)
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// Custom Settings.
|
|
|
|
api.GetClientConfig(v1)
|
2020-12-18 20:42:12 +01:00
|
|
|
api.GetSettings(v1)
|
|
|
|
api.SaveSettings(v1)
|
2022-09-28 09:01:17 +02:00
|
|
|
|
2022-10-17 19:07:38 +02:00
|
|
|
// Profile and Uploads.
|
|
|
|
api.UploadUserFiles(v1)
|
|
|
|
api.ProcessUserUpload(v1)
|
|
|
|
api.UploadUserAvatar(v1)
|
|
|
|
api.UpdateUserPassword(v1)
|
|
|
|
api.UpdateUser(v1)
|
2020-06-25 14:54:04 +02:00
|
|
|
|
2022-10-17 19:07:38 +02:00
|
|
|
// Service Accounts.
|
2022-10-15 21:54:11 +02:00
|
|
|
api.SearchServices(v1)
|
|
|
|
api.GetService(v1)
|
|
|
|
api.GetServiceFolders(v1)
|
|
|
|
api.UploadToService(v1)
|
|
|
|
api.AddService(v1)
|
|
|
|
api.DeleteService(v1)
|
|
|
|
api.UpdateService(v1)
|
2021-09-18 15:32:39 +02:00
|
|
|
|
2022-10-17 19:07:38 +02:00
|
|
|
// Thumbnail Images.
|
2020-07-13 17:25:27 +02:00
|
|
|
api.GetThumb(v1)
|
2022-10-17 19:07:38 +02:00
|
|
|
|
|
|
|
// Video Streaming.
|
2020-06-25 14:54:04 +02:00
|
|
|
api.GetVideo(v1)
|
2022-10-17 19:07:38 +02:00
|
|
|
|
|
|
|
// Downloads.
|
|
|
|
api.GetDownload(v1)
|
2022-07-21 15:16:20 +02:00
|
|
|
api.ZipCreate(v1)
|
|
|
|
api.ZipDownload(v1)
|
2020-06-25 14:54:04 +02:00
|
|
|
|
2022-10-17 19:07:38 +02:00
|
|
|
// Index and Import.
|
2022-09-28 09:01:17 +02:00
|
|
|
api.StartImport(v1)
|
|
|
|
api.CancelImport(v1)
|
|
|
|
api.StartIndexing(v1)
|
|
|
|
api.CancelIndexing(v1)
|
|
|
|
|
2022-10-17 19:07:38 +02:00
|
|
|
// Photo Search and Organization.
|
2021-09-18 15:32:39 +02:00
|
|
|
api.SearchPhotos(v1)
|
2021-11-26 13:59:10 +01:00
|
|
|
api.SearchGeo(v1)
|
2020-06-25 14:54:04 +02:00
|
|
|
api.GetPhoto(v1)
|
|
|
|
api.GetPhotoYaml(v1)
|
|
|
|
api.UpdatePhoto(v1)
|
|
|
|
api.GetPhotoDownload(v1)
|
2022-09-30 19:15:10 +02:00
|
|
|
// api.GetPhotoLinks(v1)
|
|
|
|
// api.CreatePhotoLink(v1)
|
|
|
|
// api.UpdatePhotoLink(v1)
|
|
|
|
// api.DeletePhotoLink(v1)
|
2020-06-25 14:54:04 +02:00
|
|
|
api.ApprovePhoto(v1)
|
|
|
|
api.LikePhoto(v1)
|
|
|
|
api.DislikePhoto(v1)
|
|
|
|
api.AddPhotoLabel(v1)
|
|
|
|
api.RemovePhotoLabel(v1)
|
|
|
|
api.UpdatePhotoLabel(v1)
|
|
|
|
api.GetMomentsTime(v1)
|
|
|
|
api.GetFile(v1)
|
2020-10-04 14:21:40 +02:00
|
|
|
api.DeleteFile(v1)
|
2021-08-21 16:36:00 +02:00
|
|
|
api.UpdateMarker(v1)
|
|
|
|
api.ClearMarkerSubject(v1)
|
2020-07-14 11:00:49 +02:00
|
|
|
api.PhotoPrimary(v1)
|
|
|
|
api.PhotoUnstack(v1)
|
2020-06-25 14:54:04 +02:00
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// Photo Albums.
|
2021-09-18 15:32:39 +02:00
|
|
|
api.SearchAlbums(v1)
|
2020-06-25 14:54:04 +02:00
|
|
|
api.GetAlbum(v1)
|
2021-09-18 15:32:39 +02:00
|
|
|
api.AlbumCover(v1)
|
2020-06-25 14:54:04 +02:00
|
|
|
api.CreateAlbum(v1)
|
|
|
|
api.UpdateAlbum(v1)
|
|
|
|
api.DeleteAlbum(v1)
|
|
|
|
api.DownloadAlbum(v1)
|
|
|
|
api.GetAlbumLinks(v1)
|
|
|
|
api.CreateAlbumLink(v1)
|
|
|
|
api.UpdateAlbumLink(v1)
|
|
|
|
api.DeleteAlbumLink(v1)
|
|
|
|
api.LikeAlbum(v1)
|
|
|
|
api.DislikeAlbum(v1)
|
|
|
|
api.CloneAlbums(v1)
|
|
|
|
api.AddPhotosToAlbum(v1)
|
|
|
|
api.RemovePhotosFromAlbum(v1)
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// Photo Labels.
|
2021-09-18 15:32:39 +02:00
|
|
|
api.SearchLabels(v1)
|
|
|
|
api.LabelCover(v1)
|
|
|
|
api.UpdateLabel(v1)
|
2022-09-30 19:15:10 +02:00
|
|
|
// api.GetLabelLinks(v1)
|
|
|
|
// api.CreateLabelLink(v1)
|
|
|
|
// api.UpdateLabelLink(v1)
|
|
|
|
// api.DeleteLabelLink(v1)
|
2021-09-18 15:32:39 +02:00
|
|
|
api.LikeLabel(v1)
|
|
|
|
api.DislikeLabel(v1)
|
2020-06-25 14:54:04 +02:00
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// Files and Folders.
|
2021-11-26 14:28:50 +01:00
|
|
|
api.SearchFoldersOriginals(v1)
|
|
|
|
api.SearchFoldersImport(v1)
|
2021-09-18 15:32:39 +02:00
|
|
|
api.FolderCover(v1)
|
2019-11-16 16:06:34 +01:00
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// People.
|
2021-09-18 15:32:39 +02:00
|
|
|
api.SearchSubjects(v1)
|
|
|
|
api.GetSubject(v1)
|
|
|
|
api.UpdateSubject(v1)
|
|
|
|
api.LikeSubject(v1)
|
|
|
|
api.DislikeSubject(v1)
|
|
|
|
|
|
|
|
// Faces.
|
|
|
|
api.SearchFaces(v1)
|
|
|
|
api.GetFace(v1)
|
|
|
|
api.UpdateFace(v1)
|
2020-01-24 01:33:04 +01:00
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// Batch Operations.
|
2021-09-18 15:32:39 +02:00
|
|
|
api.BatchPhotosApprove(v1)
|
|
|
|
api.BatchPhotosArchive(v1)
|
|
|
|
api.BatchPhotosRestore(v1)
|
|
|
|
api.BatchPhotosPrivate(v1)
|
|
|
|
api.BatchPhotosDelete(v1)
|
|
|
|
api.BatchAlbumsDelete(v1)
|
|
|
|
api.BatchLabelsDelete(v1)
|
|
|
|
|
2022-09-28 09:01:17 +02:00
|
|
|
// Technical Endpoints.
|
2021-09-18 15:32:39 +02:00
|
|
|
api.GetSvg(v1)
|
|
|
|
api.GetStatus(v1)
|
|
|
|
api.GetErrors(v1)
|
2022-04-03 12:37:43 +02:00
|
|
|
api.DeleteErrors(v1)
|
2021-09-18 15:32:39 +02:00
|
|
|
api.SendFeedback(v1)
|
2022-07-19 16:58:43 +02:00
|
|
|
api.Connect(v1)
|
2022-09-28 09:01:17 +02:00
|
|
|
api.WebSocket(v1)
|
2018-09-13 07:05:13 +02:00
|
|
|
}
|
|
|
|
}
|