From 8a3965f6665965ee75e5862b7ec589383bb31b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sat, 2 Dec 2023 13:15:19 +0100 Subject: [PATCH] v0.0.327 --- ginext/response.go | 33 +++++++++++++++++++++++++++++++++ goextVersion.go | 4 ++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/ginext/response.go b/ginext/response.go index e8f9c47..a427490 100644 --- a/ginext/response.go +++ b/ginext/response.go @@ -15,6 +15,7 @@ type headerval struct { type HTTPResponse interface { Write(g *gin.Context) WithHeader(k string, v string) HTTPResponse + IsSuccess() bool } type jsonHTTPResponse struct { @@ -39,6 +40,10 @@ func (j jsonHTTPResponse) WithHeader(k string, v string) HTTPResponse { return j } +func (j jsonHTTPResponse) IsSuccess() bool { + return j.statusCode >= 200 && j.statusCode <= 399 +} + type emptyHTTPResponse struct { statusCode int headers []headerval @@ -56,6 +61,10 @@ func (j emptyHTTPResponse) WithHeader(k string, v string) HTTPResponse { return j } +func (j emptyHTTPResponse) IsSuccess() bool { + return j.statusCode >= 200 && j.statusCode <= 399 +} + type textHTTPResponse struct { statusCode int data string @@ -74,6 +83,10 @@ func (j textHTTPResponse) WithHeader(k string, v string) HTTPResponse { return j } +func (j textHTTPResponse) IsSuccess() bool { + return j.statusCode >= 200 && j.statusCode <= 399 +} + type dataHTTPResponse struct { statusCode int data []byte @@ -93,6 +106,10 @@ func (j dataHTTPResponse) WithHeader(k string, v string) HTTPResponse { return j } +func (j dataHTTPResponse) IsSuccess() bool { + return j.statusCode >= 200 && j.statusCode <= 399 +} + type fileHTTPResponse struct { mimetype string filepath string @@ -117,6 +134,10 @@ func (j fileHTTPResponse) WithHeader(k string, v string) HTTPResponse { return j } +func (j fileHTTPResponse) IsSuccess() bool { + return true +} + type downloadDataHTTPResponse struct { statusCode int mimetype string @@ -142,6 +163,10 @@ func (j downloadDataHTTPResponse) WithHeader(k string, v string) HTTPResponse { return j } +func (j downloadDataHTTPResponse) IsSuccess() bool { + return j.statusCode >= 200 && j.statusCode <= 399 +} + type redirectHTTPResponse struct { statusCode int url string @@ -157,6 +182,10 @@ func (j redirectHTTPResponse) WithHeader(k string, v string) HTTPResponse { return j } +func (j redirectHTTPResponse) IsSuccess() bool { + return j.statusCode >= 200 && j.statusCode <= 399 +} + type jsonAPIErrResponse struct { err *exerr.ExErr headers []headerval @@ -171,6 +200,10 @@ func (j jsonAPIErrResponse) WithHeader(k string, v string) HTTPResponse { return j } +func (j jsonAPIErrResponse) IsSuccess() bool { + return false +} + func Status(sc int) HTTPResponse { return &emptyHTTPResponse{statusCode: sc} } diff --git a/goextVersion.go b/goextVersion.go index b7aaead..30621a2 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.326" +const GoextVersion = "0.0.327" -const GoextVersionTimestamp = "2023-12-02T13:07:36+0100" +const GoextVersionTimestamp = "2023-12-02T13:15:19+0100"