Files
mstore/app/handler/version.go
T

34 lines
705 B
Go

/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*/
package handler
import (
"net/http"
"mstore/app/imageoper"
"mstore/app/router"
)
// GET /v2/ 200 404/401
func (hand *Handler) GetVersion(rctx *router.Context) {
params := &imageoper.GetVersionParams{}
//hand.DumpHeaders("GetVersion", rctx)
authorization := rctx.GetHeader("Authorization")
if authorization == "" {
rctx.SetHeader("WWW-Authenticate", `Basic realm="mstore"`)
//rctx.SetStatus(http.StatusUnauthorized)
rctx.SetStatus(http.StatusOK)
return
}
ctx := rctx.GetContext()
_, code, err := hand.imop.GetVersion(ctx, params)
if err != nil {
hand.logg.Errorf("GetVersion error: %v", err)
}
rctx.SetStatus(code)
}