splitted one operator module to file, account, image operators; splitted operator functions; etc
This commit is contained in:
@@ -52,9 +52,9 @@ func (hand *Handler) CheckAccess(rctx *router.Context) (bool, string, error) {
|
||||
|
||||
accountID = terms.AnonymousID
|
||||
|
||||
hand.logg.Debugf("URL: %s", rctx.URL().String())
|
||||
hand.logg.Debugf("URL: %s", rctx.URL().String())
|
||||
authHeader := rctx.GetHeader("Authorization")
|
||||
hand.logg.Debugf("Authorization: %s", authHeader)
|
||||
hand.logg.Debugf("Authorization: %s", authHeader)
|
||||
if authHeader != "" {
|
||||
username, password, err = auxhttp.ParseBasicAuth(authHeader)
|
||||
if err != nil {
|
||||
|
||||
+11
-11
@@ -12,7 +12,7 @@ package handler
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"mstore/app/operator"
|
||||
"mstore/app/accoper"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
)
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
func (hand *Handler) CreateAccount(rctx *router.Context) {
|
||||
var err error
|
||||
|
||||
params := &operator.CreateAccountParams{}
|
||||
params := &accoper.CreateAccountParams{}
|
||||
err = rctx.BindJSON(params)
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
@@ -41,7 +41,7 @@ func (hand *Handler) CreateAccount(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, err := hand.oper.CreateAccount(rctx.Ctx, operatorID, params)
|
||||
res, err := hand.acop.CreateAccount(rctx.Ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -54,7 +54,7 @@ func (hand *Handler) CreateAccount(rctx *router.Context) {
|
||||
func (hand *Handler) GetAccount(rctx *router.Context) {
|
||||
var err error
|
||||
|
||||
params := &operator.GetAccountParams{}
|
||||
params := &accoper.GetAccountParams{}
|
||||
err = rctx.BindJSON(params)
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
@@ -74,7 +74,7 @@ func (hand *Handler) GetAccount(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, err := hand.oper.GetAccount(rctx.Ctx, operatorID, params)
|
||||
res, err := hand.acop.GetAccount(rctx.Ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -87,7 +87,7 @@ func (hand *Handler) GetAccount(rctx *router.Context) {
|
||||
func (hand *Handler) ListAccounts(rctx *router.Context) {
|
||||
var err error
|
||||
|
||||
params := &operator.ListAccountsParams{}
|
||||
params := &accoper.ListAccountsParams{}
|
||||
err = rctx.BindJSON(params)
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
@@ -107,7 +107,7 @@ func (hand *Handler) ListAccounts(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, err := hand.oper.ListAccounts(rctx.Ctx, params)
|
||||
res, err := hand.acop.ListAccounts(rctx.Ctx, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("ListAccounts error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -120,7 +120,7 @@ func (hand *Handler) ListAccounts(rctx *router.Context) {
|
||||
func (hand *Handler) UpdateAccount(rctx *router.Context) {
|
||||
var err error
|
||||
|
||||
params := &operator.UpdateAccountParams{}
|
||||
params := &accoper.UpdateAccountParams{}
|
||||
err = rctx.BindJSON(params)
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
@@ -140,7 +140,7 @@ func (hand *Handler) UpdateAccount(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, err := hand.oper.UpdateAccount(rctx.Ctx, operatorID, params)
|
||||
res, err := hand.acop.UpdateAccount(rctx.Ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("UpdateAccount error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -153,7 +153,7 @@ func (hand *Handler) UpdateAccount(rctx *router.Context) {
|
||||
func (hand *Handler) DeleteAccount(rctx *router.Context) {
|
||||
var err error
|
||||
|
||||
params := &operator.DeleteAccountParams{}
|
||||
params := &accoper.DeleteAccountParams{}
|
||||
err = rctx.BindJSON(params)
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
@@ -173,7 +173,7 @@ func (hand *Handler) DeleteAccount(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, err := hand.oper.DeleteAccount(rctx.Ctx, operatorID, params)
|
||||
res, err := hand.acop.DeleteAccount(rctx.Ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("DeleteAccount error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
|
||||
+13
-15
@@ -14,7 +14,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"mstore/app/operator"
|
||||
"mstore/app/imageoper"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
)
|
||||
@@ -26,7 +26,7 @@ func (hand *Handler) BlobExists(rctx *router.Context) {
|
||||
|
||||
//hand.DumpHeaders("BlobExists", rctx)
|
||||
|
||||
params := &operator.BlobExistsParams{
|
||||
params := &imageoper.BlobExistsParams{
|
||||
Name: name,
|
||||
Digest: digest,
|
||||
}
|
||||
@@ -43,7 +43,7 @@ func (hand *Handler) BlobExists(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
res, code, err := hand.oper.BlobExists(ctx, operatorID, params)
|
||||
res, code, err := hand.imop.BlobExists(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("BlobExist error: %v", err)
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func (hand *Handler) PostUpload(rctx *router.Context) {
|
||||
mount := rctx.GetQuery("mount")
|
||||
from := rctx.GetQuery("from")
|
||||
|
||||
params := &operator.PostUploadParams{
|
||||
params := &imageoper.PostUploadParams{
|
||||
Name: name,
|
||||
Digest: digest,
|
||||
Mount: mount,
|
||||
@@ -93,7 +93,7 @@ func (hand *Handler) PostUpload(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, code, err := hand.oper.PostUpload(rctx.Ctx, operatorID, params)
|
||||
res, code, err := hand.imop.PostUpload(rctx.Ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("PostUpload error: %v", err)
|
||||
} else {
|
||||
@@ -104,8 +104,6 @@ func (hand *Handler) PostUpload(rctx *router.Context) {
|
||||
rctx.SetStatus(code)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// PATCH /v2/<name>/blobs/uploads/<reference> 202 404/416
|
||||
func (hand *Handler) PatchUpload(rctx *router.Context) {
|
||||
|
||||
@@ -117,7 +115,7 @@ func (hand *Handler) PatchUpload(rctx *router.Context) {
|
||||
reference, _ := rctx.GetSubpath("reference")
|
||||
reader := rctx.Request.Body
|
||||
|
||||
params := &operator.PatchUploadParams{
|
||||
params := &imageoper.PatchUploadParams{
|
||||
ContentLength: contentLength,
|
||||
ContentType: contentType,
|
||||
ContentRange: contentRange,
|
||||
@@ -138,7 +136,7 @@ func (hand *Handler) PatchUpload(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
res, code, err := hand.oper.PatchUpload(ctx, operatorID, params)
|
||||
res, code, err := hand.imop.PatchUpload(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("PatchUpload error: %v", err)
|
||||
}
|
||||
@@ -162,7 +160,7 @@ func (hand *Handler) PutUpload(rctx *router.Context) {
|
||||
digest := rctx.GetQuery("digest")
|
||||
reader := rctx.Request.Body
|
||||
|
||||
params := &operator.PutUploadParams{
|
||||
params := &imageoper.PutUploadParams{
|
||||
ContentLength: contentLength,
|
||||
ContentType: contentType,
|
||||
ContentRange: contentRange,
|
||||
@@ -183,7 +181,7 @@ func (hand *Handler) PutUpload(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, code, err := hand.oper.PutUpload(rctx.Ctx, operatorID, params)
|
||||
res, code, err := hand.imop.PutUpload(rctx.Ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("PutUpload error: %v", err)
|
||||
}
|
||||
@@ -197,7 +195,7 @@ func (hand *Handler) GetBlob(rctx *router.Context) {
|
||||
name, _ := rctx.GetSubpath("name")
|
||||
digest, _ := rctx.GetSubpath("digest")
|
||||
|
||||
params := &operator.GetBlobParams{
|
||||
params := &imageoper.GetBlobParams{
|
||||
Name: name,
|
||||
Digest: digest,
|
||||
}
|
||||
@@ -214,7 +212,7 @@ func (hand *Handler) GetBlob(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
res, code, err := hand.oper.GetBlob(ctx, operatorID, params)
|
||||
res, code, err := hand.imop.GetBlob(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("GetBlob error: %v", err)
|
||||
}
|
||||
@@ -243,7 +241,7 @@ func (hand *Handler) DeleteBlob(rctx *router.Context) {
|
||||
name, _ := rctx.GetSubpath("name")
|
||||
digest, _ := rctx.GetSubpath("digest")
|
||||
|
||||
params := &operator.DeleteBlobParams{
|
||||
params := &imageoper.DeleteBlobParams{
|
||||
Name: name,
|
||||
Digest: digest,
|
||||
}
|
||||
@@ -260,7 +258,7 @@ func (hand *Handler) DeleteBlob(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
_, code, err := hand.oper.DeleteBlob(ctx, operatorID, params)
|
||||
_, code, err := hand.imop.DeleteBlob(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("DeleteBlob error: %v", err)
|
||||
}
|
||||
|
||||
+15
-15
@@ -13,7 +13,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"mstore/app/operator"
|
||||
"mstore/app/fileoper"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
)
|
||||
@@ -23,7 +23,7 @@ const zeroContentLength = "0"
|
||||
func (hand *Handler) FileInfo(rctx *router.Context) {
|
||||
|
||||
filepath, _ := rctx.GetSubpath("filepath")
|
||||
params := &operator.FileInfoParams{
|
||||
params := &fileoper.FileInfoParams{
|
||||
Filepath: filepath,
|
||||
}
|
||||
// Rigth checking
|
||||
@@ -39,7 +39,7 @@ func (hand *Handler) FileInfo(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
code, res, err := hand.oper.FileInfo(ctx, operatorID, params)
|
||||
code, res, err := hand.fiop.FileInfo(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("FileInfo error: %v", err)
|
||||
rctx.SetStatus(code)
|
||||
@@ -65,7 +65,7 @@ func (hand *Handler) PutFile(rctx *router.Context) {
|
||||
contentType := rctx.GetHeader("Content-Type")
|
||||
filepath, _ := rctx.GetSubpath("filepath")
|
||||
|
||||
params := &operator.PutFileParams{
|
||||
params := &fileoper.PutFileParams{
|
||||
Filepath: filepath,
|
||||
ContentType: contentType,
|
||||
ContentSize: contentSize,
|
||||
@@ -84,7 +84,7 @@ func (hand *Handler) PutFile(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
code, _, err := hand.oper.PutFile(ctx, operatorID, params)
|
||||
code, _, err := hand.fiop.PutFile(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("PutFile error: %v", err)
|
||||
rctx.SetStatus(code)
|
||||
@@ -96,7 +96,7 @@ func (hand *Handler) PutFile(rctx *router.Context) {
|
||||
func (hand *Handler) GetFile(rctx *router.Context) {
|
||||
|
||||
filepath, _ := rctx.GetSubpath("filepath")
|
||||
params := &operator.GetFileParams{
|
||||
params := &fileoper.GetFileParams{
|
||||
Filepath: filepath,
|
||||
}
|
||||
// Rigth checking
|
||||
@@ -112,7 +112,7 @@ func (hand *Handler) GetFile(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
code, res, err := hand.oper.GetFile(ctx, operatorID, params)
|
||||
code, res, err := hand.fiop.GetFile(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("PutFile error: %v", err)
|
||||
rctx.SetStatus(code)
|
||||
@@ -144,7 +144,7 @@ func (hand *Handler) GetFile(rctx *router.Context) {
|
||||
func (hand *Handler) DeleteFile(rctx *router.Context) {
|
||||
|
||||
filepath, _ := rctx.GetSubpath("filepath")
|
||||
params := &operator.DeleteFileParams{
|
||||
params := &fileoper.DeleteFileParams{
|
||||
Filepath: filepath,
|
||||
}
|
||||
// Rigth checking
|
||||
@@ -160,7 +160,7 @@ func (hand *Handler) DeleteFile(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
code, _, err := hand.oper.DeleteFile(ctx, operatorID, params)
|
||||
code, _, err := hand.fiop.DeleteFile(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("DeleteFIle error: %v", err)
|
||||
}
|
||||
@@ -174,7 +174,7 @@ func (hand *Handler) ListFiles(rctx *router.Context) {
|
||||
if filepath == "" {
|
||||
filepath = "/"
|
||||
}
|
||||
params := &operator.ListFilesParams{
|
||||
params := &fileoper.ListFilesParams{
|
||||
Filepath: filepath,
|
||||
}
|
||||
err := rctx.BindQuery(params)
|
||||
@@ -197,7 +197,7 @@ func (hand *Handler) ListFiles(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
code, res, err := hand.oper.ListFiles(ctx, operatorID, params)
|
||||
code, res, err := hand.fiop.ListFiles(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("ListFiles error: %v", err)
|
||||
rctx.SetStatus(code)
|
||||
@@ -212,7 +212,7 @@ func (hand *Handler) ListCollections(rctx *router.Context) {
|
||||
if cpath == "" {
|
||||
cpath = "/"
|
||||
}
|
||||
params := &operator.ListCollectionsParams{
|
||||
params := &fileoper.ListCollectionsParams{
|
||||
Path: cpath,
|
||||
}
|
||||
err := rctx.BindQuery(params)
|
||||
@@ -234,7 +234,7 @@ func (hand *Handler) ListCollections(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
code, res, err := hand.oper.ListCollections(ctx, operatorID, params)
|
||||
code, res, err := hand.fiop.ListCollections(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("ListCollections error: %v", err)
|
||||
rctx.SetStatus(code)
|
||||
@@ -249,7 +249,7 @@ func (hand *Handler) DeleteCollection(rctx *router.Context) {
|
||||
if cpath == "" {
|
||||
cpath = "/"
|
||||
}
|
||||
params := &operator.DeleteColletionParams{
|
||||
params := &fileoper.DeleteColletionParams{
|
||||
Path: cpath,
|
||||
}
|
||||
err := rctx.BindQuery(params)
|
||||
@@ -272,7 +272,7 @@ func (hand *Handler) DeleteCollection(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
code, res, err := hand.oper.DeleteColletion(ctx, operatorID, params)
|
||||
code, res, err := hand.fiop.DeleteColletion(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("DeleteColletion error: %v", err)
|
||||
rctx.SetStatus(code)
|
||||
|
||||
+11
-11
@@ -12,7 +12,7 @@ package handler
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"mstore/app/operator"
|
||||
"mstore/app/accoper"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
)
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
func (hand *Handler) CreateGrant(rctx *router.Context) {
|
||||
var err error
|
||||
|
||||
params := &operator.CreateGrantParams{}
|
||||
params := &accoper.CreateGrantParams{}
|
||||
err = rctx.BindJSON(params)
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
@@ -41,7 +41,7 @@ func (hand *Handler) CreateGrant(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, err := hand.oper.CreateGrant(rctx.Ctx, operatorID, params)
|
||||
res, err := hand.acop.CreateGrant(rctx.Ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("CreateGrant error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -54,7 +54,7 @@ func (hand *Handler) CreateGrant(rctx *router.Context) {
|
||||
func (hand *Handler) GetGrant(rctx *router.Context) {
|
||||
var err error
|
||||
|
||||
params := &operator.GetGrantParams{}
|
||||
params := &accoper.GetGrantParams{}
|
||||
err = rctx.BindJSON(params)
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
@@ -74,7 +74,7 @@ func (hand *Handler) GetGrant(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, err := hand.oper.GetGrant(rctx.Ctx, operatorID, params)
|
||||
res, err := hand.acop.GetGrant(rctx.Ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("CreateGrant error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -87,7 +87,7 @@ func (hand *Handler) GetGrant(rctx *router.Context) {
|
||||
func (hand *Handler) ListGrants(rctx *router.Context) {
|
||||
var err error
|
||||
|
||||
params := &operator.ListGrantsParams{}
|
||||
params := &accoper.ListGrantsParams{}
|
||||
err = rctx.BindJSON(params)
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
@@ -107,7 +107,7 @@ func (hand *Handler) ListGrants(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, err := hand.oper.ListGrants(rctx.Ctx, operatorID, params)
|
||||
res, err := hand.acop.ListGrants(rctx.Ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("ListGrants error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -120,7 +120,7 @@ func (hand *Handler) ListGrants(rctx *router.Context) {
|
||||
func (hand *Handler) UpdateGrant(rctx *router.Context) {
|
||||
var err error
|
||||
|
||||
params := &operator.UpdateGrantParams{}
|
||||
params := &accoper.UpdateGrantParams{}
|
||||
err = rctx.BindJSON(params)
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
@@ -140,7 +140,7 @@ func (hand *Handler) UpdateGrant(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, err := hand.oper.UpdateGrant(rctx.Ctx, operatorID, params)
|
||||
res, err := hand.acop.UpdateGrant(rctx.Ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("UpdateGrant error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -153,7 +153,7 @@ func (hand *Handler) UpdateGrant(rctx *router.Context) {
|
||||
func (hand *Handler) DeleteGrant(rctx *router.Context) {
|
||||
var err error
|
||||
|
||||
params := &operator.DeleteGrantParams{}
|
||||
params := &accoper.DeleteGrantParams{}
|
||||
err = rctx.BindJSON(params)
|
||||
if err != nil {
|
||||
hand.SendError(rctx, err)
|
||||
@@ -173,7 +173,7 @@ func (hand *Handler) DeleteGrant(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, err := hand.oper.DeleteGrant(rctx.Ctx, operatorID, params)
|
||||
res, err := hand.acop.DeleteGrant(rctx.Ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("DeleteGrant error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
|
||||
+15
-5
@@ -12,28 +12,38 @@ package handler
|
||||
import (
|
||||
"mstore/app/logger"
|
||||
"mstore/app/maindb"
|
||||
"mstore/app/operator"
|
||||
"mstore/app/router"
|
||||
|
||||
"mstore/app/accoper"
|
||||
"mstore/app/fileoper"
|
||||
"mstore/app/imageoper"
|
||||
|
||||
yaml "go.yaml.in/yaml/v4"
|
||||
)
|
||||
|
||||
type HandlerParams struct {
|
||||
Operator *operator.Operator
|
||||
MainDB *maindb.Database
|
||||
MainDB *maindb.Database
|
||||
FileOper *fileoper.Operator
|
||||
AccOper *accoper.Operator
|
||||
ImageOper *imageoper.Operator
|
||||
}
|
||||
|
||||
type Handler struct {
|
||||
oper *operator.Operator
|
||||
mdb *maindb.Database
|
||||
logg *logger.Logger
|
||||
|
||||
fiop *fileoper.Operator
|
||||
acop *accoper.Operator
|
||||
imop *imageoper.Operator
|
||||
}
|
||||
|
||||
func NewHandler(params *HandlerParams) (*Handler, error) {
|
||||
var err error
|
||||
hand := &Handler{
|
||||
oper: params.Operator,
|
||||
mdb: params.MainDB,
|
||||
fiop: params.FileOper,
|
||||
acop: params.AccOper,
|
||||
imop: params.ImageOper,
|
||||
}
|
||||
hand.logg = logger.NewLoggerWithSubject("handler")
|
||||
return hand, err
|
||||
|
||||
+15
-15
@@ -12,7 +12,7 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"mstore/app/operator"
|
||||
"mstore/app/imageoper"
|
||||
"mstore/app/router"
|
||||
"mstore/pkg/terms"
|
||||
)
|
||||
@@ -23,7 +23,7 @@ func (hand *Handler) ManifestExists(rctx *router.Context) {
|
||||
|
||||
//hand.DumpHeaders("ManigestExists:\n", rctx)
|
||||
|
||||
params := &operator.ManifestExistsParams{
|
||||
params := &imageoper.ManifestExistsParams{
|
||||
Name: name,
|
||||
Reference: reference,
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func (hand *Handler) ManifestExists(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
res, code, err := hand.oper.ManifestExists(ctx, params)
|
||||
res, code, err := hand.imop.ManifestExists(ctx, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("ManifestExist error: %v", err)
|
||||
} else if code == http.StatusOK {
|
||||
@@ -62,7 +62,7 @@ func (hand *Handler) PutManifest(rctx *router.Context) {
|
||||
name, _ := rctx.GetSubpath("name")
|
||||
reference, _ := rctx.GetSubpath("reference")
|
||||
|
||||
params := &operator.PutManifestParams{
|
||||
params := &imageoper.PutManifestParams{
|
||||
ContentType: contentType,
|
||||
ContentLength: contentLength,
|
||||
Name: name,
|
||||
@@ -82,7 +82,7 @@ func (hand *Handler) PutManifest(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
res, code, err := hand.oper.PutManifest(ctx, params)
|
||||
res, code, err := hand.imop.PutManifest(ctx, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("PutManifest error: %v", err)
|
||||
} else {
|
||||
@@ -98,7 +98,7 @@ func (hand *Handler) GetManifest(rctx *router.Context) {
|
||||
|
||||
//hand.DumpHeaders("GetManigest", rctx)
|
||||
|
||||
params := &operator.GetManifestParams{
|
||||
params := &imageoper.GetManifestParams{
|
||||
Name: name,
|
||||
Reference: reference,
|
||||
}
|
||||
@@ -115,7 +115,7 @@ func (hand *Handler) GetManifest(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
res, code, err := hand.oper.GetManifest(ctx, params)
|
||||
res, code, err := hand.imop.GetManifest(ctx, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("GetManifest error: %v", err)
|
||||
rctx.SetStatus(code)
|
||||
@@ -138,7 +138,7 @@ func (hand *Handler) DeleteManifest(rctx *router.Context) {
|
||||
name, _ := rctx.GetSubpath("name")
|
||||
reference, _ := rctx.GetSubpath("reference")
|
||||
|
||||
params := &operator.DeleteManifestParams{
|
||||
params := &imageoper.DeleteManifestParams{
|
||||
Name: name,
|
||||
Reference: reference,
|
||||
}
|
||||
@@ -155,7 +155,7 @@ func (hand *Handler) DeleteManifest(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
_, code, err := hand.oper.DeleteManifest(ctx, params)
|
||||
_, code, err := hand.imop.DeleteManifest(ctx, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("DeleteManifest error: %v", err)
|
||||
}
|
||||
@@ -167,7 +167,7 @@ func (hand *Handler) DeleteManifest(rctx *router.Context) {
|
||||
func (hand *Handler) GetReferer(rctx *router.Context) {
|
||||
name, _ := rctx.GetSubpath("name")
|
||||
digest, _ := rctx.GetSubpath("digest")
|
||||
params := &operator.GetRefererParams{
|
||||
params := &imageoper.GetRefererParams{
|
||||
Name: name,
|
||||
Digest: digest,
|
||||
}
|
||||
@@ -183,7 +183,7 @@ func (hand *Handler) GetReferer(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
res, code, err := hand.oper.GetReferer(rctx.Ctx, params)
|
||||
res, code, err := hand.imop.GetReferer(rctx.Ctx, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("GetReferer error: %v", err)
|
||||
}
|
||||
@@ -194,7 +194,7 @@ func (hand *Handler) GetReferer(rctx *router.Context) {
|
||||
// GET /v2/<name>/tags/list?n=<integer>&last=<integer>
|
||||
func (hand *Handler) GetTags(rctx *router.Context) {
|
||||
name, _ := rctx.GetSubpath("name")
|
||||
params := &operator.GetTagsParams{
|
||||
params := &imageoper.GetTagsParams{
|
||||
Name: name,
|
||||
}
|
||||
// Rigth checking
|
||||
@@ -210,7 +210,7 @@ func (hand *Handler) GetTags(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
res, code, err := hand.oper.GetTags(ctx, params)
|
||||
res, code, err := hand.imop.GetTags(ctx, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("GetTags error: %v", err)
|
||||
}
|
||||
@@ -219,7 +219,7 @@ func (hand *Handler) GetTags(rctx *router.Context) {
|
||||
|
||||
// GET /v2/_catalog?n=1000 200 404
|
||||
func (hand *Handler) ListManifests(rctx *router.Context) {
|
||||
params := &operator.ListManifestsParams{}
|
||||
params := &imageoper.ListManifestsParams{}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightReadImages, "_catalog")
|
||||
@@ -233,7 +233,7 @@ func (hand *Handler) ListManifests(rctx *router.Context) {
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
res, code, err := hand.oper.ListManifests(ctx, params)
|
||||
res, code, err := hand.imop.ListManifests(ctx, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("ListManifests error: %v", err)
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"mstore/app/operator"
|
||||
"mstore/app/imageoper"
|
||||
"mstore/app/router"
|
||||
)
|
||||
|
||||
func (hand *Handler) SendHello(rctx *router.Context) {
|
||||
params := &operator.SendHelloParams{}
|
||||
res, _ := hand.oper.SendHello(params)
|
||||
params := &imageoper.SendHelloParams{}
|
||||
res, _ := hand.imop.SendHello(params)
|
||||
hand.SendResult(rctx, res)
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"mstore/app/operator"
|
||||
"mstore/app/imageoper"
|
||||
"mstore/app/router"
|
||||
)
|
||||
|
||||
// GET /v2/ 200 404/401
|
||||
func (hand *Handler) GetVersion(rctx *router.Context) {
|
||||
params := &operator.GetVersionParams{}
|
||||
params := &imageoper.GetVersionParams{}
|
||||
|
||||
//hand.DumpHeaders("GetVersion", rctx)
|
||||
authorization := rctx.GetHeader("Authorization")
|
||||
@@ -28,7 +28,7 @@ func (hand *Handler) GetVersion(rctx *router.Context) {
|
||||
return
|
||||
}
|
||||
ctx := rctx.GetContext()
|
||||
_, code, err := hand.oper.GetVersion(ctx, params)
|
||||
_, code, err := hand.imop.GetVersion(ctx, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("GetVersion error: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user