package http import ( "github.com/gin-gonic/gin" "gitlink.org.cn/cloudream/jcs-pub/client/internal/http/auth" "gitlink.org.cn/cloudream/jcs-pub/client/internal/http/types" "gitlink.org.cn/cloudream/jcs-pub/client/internal/services" cliapi "gitlink.org.cn/cloudream/jcs-pub/client/sdk/api/v1" ) type Server struct { svc *services.Service cfg *types.Config } func NewServer(cfg *types.Config, svc *services.Service) *Server { return &Server{ cfg: cfg, svc: svc, } } func (s *Server) InitRouters(rt gin.IRoutes, ah *auth.Auth) { certAuth := ah.RejectNoCertAuth signAuth := ah.Presigned rt.GET(cliapi.ObjectListPathByPath, certAuth, s.Object().ListByPath) rt.GET(cliapi.ObjectListByIDsPath, certAuth, s.Object().ListByIDs) rt.GET(cliapi.ObjectDownloadPath, certAuth, s.Object().Download) rt.GET(cliapi.ObjectDownloadByPathPath, certAuth, s.Object().DownloadByPath) rt.POST(cliapi.ObjectUploadPath, certAuth, s.Object().Upload) rt.GET(cliapi.ObjectGetPackageObjectsPath, certAuth, s.Object().GetPackageObjects) rt.POST(cliapi.ObjectUpdateInfoPath, certAuth, s.Object().UpdateInfo) rt.POST(cliapi.ObjectUpdateInfoByPathPath, certAuth, s.Object().UpdateInfoByPath) rt.POST(cliapi.ObjectMovePath, certAuth, s.Object().Move) rt.POST(cliapi.ObjectDeletePath, certAuth, s.Object().Delete) rt.POST(cliapi.ObjectDeleteByPathPath, certAuth, s.Object().DeleteByPath) rt.POST(cliapi.ObjectClonePath, certAuth, s.Object().Clone) rt.GET(cliapi.PackageGetPath, certAuth, s.Package().Get) rt.GET(cliapi.PackageGetByFullNamePath, certAuth, s.Package().GetByFullName) rt.POST(cliapi.PackageCreatePath, certAuth, s.Package().Create) rt.POST(cliapi.PackageCreateUploadPath, certAuth, s.Package().CreateLoad) rt.POST(cliapi.PackageDeletePath, certAuth, s.Package().Delete) rt.POST(cliapi.PackageClonePath, certAuth, s.Package().Clone) rt.GET(cliapi.PackageDownloadPath, certAuth, s.Package().Download) rt.GET(cliapi.PackageListBucketPackagesPath, certAuth, s.Package().ListBucketPackages) rt.POST(cliapi.UserSpaceDownloadPackagePath, certAuth, s.UserSpace().DownloadPackage) rt.POST(cliapi.UserSpaceCreatePackagePath, certAuth, s.UserSpace().CreatePackage) rt.GET(cliapi.UserSpaceGetPath, certAuth, s.UserSpace().Get) rt.GET(cliapi.UserSpaceGetByNamePath, certAuth, s.UserSpace().GetByName) rt.GET(cliapi.UserSpaceGetAllPath, certAuth, s.UserSpace().GetAll) rt.POST(cliapi.UserSpaceCreatePath, certAuth, s.UserSpace().Create) rt.POST(cliapi.UserSpaceUpdatePath, certAuth, s.UserSpace().Update) rt.POST(cliapi.UserSpaceDeletePath, certAuth, s.UserSpace().Delete) rt.POST(cliapi.UserSpaceTestPath, certAuth, s.UserSpace().Test) rt.GET(cliapi.BucketGetPath, certAuth, s.Bucket().Get) rt.GET(cliapi.BucketGetByNamePath, certAuth, s.Bucket().GetByName) rt.POST(cliapi.BucketCreatePath, certAuth, s.Bucket().Create) rt.POST(cliapi.BucketDeletePath, certAuth, s.Bucket().Delete) rt.GET(cliapi.BucketListAllPath, certAuth, s.Bucket().ListAll) rt.POST(cliapi.ObjectNewMultipartUploadPath, certAuth, s.Object().NewMultipartUpload) rt.POST(cliapi.ObjectUploadPartPath, certAuth, s.Object().UploadPart) rt.POST(cliapi.ObjectCompleteMultipartUploadPath, certAuth, s.Object().CompleteMultipartUpload) rt.POST(cliapi.SpaceSyncerCreateTaskPath, certAuth, s.SpaceSyncer().CreateTask) rt.GET(cliapi.SpaceSyncerGetTaskPath, certAuth, s.SpaceSyncer().GetTask) rt.POST(cliapi.SpaceSyncerCancelTaskPath, certAuth, s.SpaceSyncer().CancelTask) rt.GET(cliapi.PresignedObjectListByPathPath, signAuth, s.Presigned().ObjectListByPath) rt.GET(cliapi.PresignedObjectDownloadByPathPath, signAuth, s.Presigned().ObjectDownloadByPath) rt.GET(cliapi.PresignedObjectDownloadPath, signAuth, s.Presigned().ObjectDownload) rt.POST(cliapi.PresignedObjectUploadPath, signAuth, s.Presigned().ObjectUpload) rt.POST(cliapi.PresignedObjectNewMultipartUploadPath, signAuth, s.Presigned().ObjectNewMultipartUpload) rt.POST(cliapi.PresignedObjectUploadPartPath, signAuth, s.Presigned().ObjectUploadPart) rt.POST(cliapi.PresignedObjectCompleteMultipartUploadPath, signAuth, s.Presigned().ObjectCompleteMultipartUpload) rt.GET(cliapi.MountDumpStatusPath, certAuth, s.Mount().DumpStatus) rt.POST(cliapi.MountStartReclaimSpacePath, certAuth, s.Mount().StartReclaimSpace) rt.GET(cliapi.TickTockListJobsPath, certAuth, s.TickTock().ListJobs) rt.POST(cliapi.TickTockRunJobPath, certAuth, s.TickTock().RunJob) rt.GET(cliapi.SystemStatusPath, certAuth, s.System().Status) rt.POST(cliapi.PubShardsCreatePath, certAuth, s.PubShards().Create) rt.POST(cliapi.PubShardsJoinPath, certAuth, s.PubShards().Join) rt.GET(cliapi.PubShardsListPath, certAuth, s.PubShards().List) rt.GET(cliapi.PubShardsGetPath, certAuth, s.PubShards().Get) rt.GET(cliapi.PubShardsExportPackagePath, certAuth, s.PubShards().ExportPackage) rt.POST(cliapi.PubShardsImportPackagePath, certAuth, s.PubShards().ImportPackage) }