From 81d01d980118ad381cf114ea2677bce49f2c0d75 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Tue, 5 Sep 2023 11:26:39 +0300 Subject: [PATCH] change base response --- .gitignore | 3 ++- elements/forms/server.go | 3 +-- .../gin/domains/discovery/resources/v1/controllers/me.go | 2 +- extensions/servers/gin/server.go | 6 +++--- main/discovery/discovery.go | 2 +- main/gin/validate_headers/server.go | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 48b7ef6..59f76db 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ build tmp main/ci/agent/agent main -build-errors.log \ No newline at end of file +build-errors.log +.air.toml \ No newline at end of file diff --git a/elements/forms/server.go b/elements/forms/server.go index 13b7d51..88a4e4a 100644 --- a/elements/forms/server.go +++ b/elements/forms/server.go @@ -98,8 +98,7 @@ type TyphoonServer struct { } type ErrorResponse struct { - Message string `json:"message"` - Status bool `json:"status"` + Error string `json:"error"` } func (s *TyphoonServer) GetDocs() []byte { diff --git a/extensions/servers/gin/domains/discovery/resources/v1/controllers/me.go b/extensions/servers/gin/domains/discovery/resources/v1/controllers/me.go index a203b3e..9ed2f86 100644 --- a/extensions/servers/gin/domains/discovery/resources/v1/controllers/me.go +++ b/extensions/servers/gin/domains/discovery/resources/v1/controllers/me.go @@ -50,7 +50,7 @@ func meHandler(ctx *gin.Context, logger interfaces.LoggerInterface) { // //println(fmt.Sprintf("%+v; %+v", m, ctx.Params, ctx.Quer)) - ctx.JSON(400, &forms.ErrorResponse{Message: err.Error()}) + ctx.JSON(400, &forms.ErrorResponse{Error: err.Error()}) return } diff --git a/extensions/servers/gin/server.go b/extensions/servers/gin/server.go index 31bccb3..ab37a1c 100644 --- a/extensions/servers/gin/server.go +++ b/extensions/servers/gin/server.go @@ -66,7 +66,7 @@ func (s *TyphoonGinServer) onRequestHandler(ginCtx *Gin.Context) { if action == nil { s.LOG.Error(Errors.ActionPathNotFound.Error()) - ginCtx.JSON(404, forms.ErrorResponse{Message: "not found", Status: false}) + ginCtx.JSON(404, forms.ErrorResponse{Error: "not found"}) return } @@ -82,7 +82,7 @@ func (s *TyphoonGinServer) onRequestHandler(ginCtx *Gin.Context) { paramsQuery := action.GetParams() if paramsQuery != nil { if err := ginCtx.BindQuery(paramsQuery); err != nil { - ginCtx.JSON(422, forms.ErrorResponse{Message: "unavailable query string", Status: false}) + ginCtx.JSON(422, forms.ErrorResponse{Error: "unavailable query string"}) return } } @@ -90,7 +90,7 @@ func (s *TyphoonGinServer) onRequestHandler(ginCtx *Gin.Context) { if action.IsValidRequestBody() { if err := ginCtx.ShouldBindJSON(action.GetRequestModel()); err != nil { s.LOG.Error(Errors.ActionErrRequestModel.Error()) - ginCtx.JSON(422, forms.ErrorResponse{Message: "unprocessable entity", Status: false}) + ginCtx.JSON(422, forms.ErrorResponse{Error: "unprocessable entity"}) return } } diff --git a/main/discovery/discovery.go b/main/discovery/discovery.go index 6c911a1..d9a22e8 100644 --- a/main/discovery/discovery.go +++ b/main/discovery/discovery.go @@ -7,7 +7,7 @@ import ( func main() { logrus.Info("starting discovery local server ...") - _ = discovery.Constructor("localhost", 12735, "http", + _ = discovery.Constructor("localhost:12735", 12735, "http", nil, nil, nil).Run() diff --git a/main/gin/validate_headers/server.go b/main/gin/validate_headers/server.go index 307d2a5..5196f50 100644 --- a/main/gin/validate_headers/server.go +++ b/main/gin/validate_headers/server.go @@ -74,7 +74,7 @@ type HeaderModel struct { var TestAction = &gin.Action{ Action: &forms.Action{ - Params: &MeParams{}, + //Params: &MeParams{}, Headers: forms.HeaderRequestModel{ ErrorModel: ErrorResponseHeaderModel{ Message: "header error",