From 98909359c6cfa4fe7e17ccd9b692c4e070b88687 Mon Sep 17 00:00:00 2001 From: shuitai Date: Wed, 9 Dec 2020 21:25:51 +0800 Subject: [PATCH] update --- restx/httpx/response.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 restx/httpx/response.go diff --git a/restx/httpx/response.go b/restx/httpx/response.go new file mode 100644 index 0000000..dbfe0d3 --- /dev/null +++ b/restx/httpx/response.go @@ -0,0 +1,31 @@ +package httpx + +import ( + "github.com/gofiber/fiber/v2" + "github.com/shuitai/coney-framework/core/logx" + "net/http" +) + +func Error(c *fiber.Ctx, code int, err error) { + c.Status(code) + logx.Error(err.Error()) +} + +func ErrorCode(c *fiber.Ctx, code int) { + c.Status(code) +} + +func ErrorJson(c *fiber.Ctx, code int, v interface{}, err error) { + c.Status(code) + c.JSON(v) + logx.Error(err.Error()) +} + +func Ok(c *fiber.Ctx) { + c.Status(http.StatusOK) +} + +func OkJson(c *fiber.Ctx, v interface{}) { + c.Status(http.StatusOK) + c.JSON(v) +} \ No newline at end of file