From 6fc1fc1d358714bcbfa22c5db566718ee03f7f52 Mon Sep 17 00:00:00 2001 From: Yuto Watanabe Date: Sun, 8 Aug 2021 17:40:11 +0900 Subject: [PATCH] added status code --- status.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/status.go b/status.go index 271d063..268df06 100644 --- a/status.go +++ b/status.go @@ -24,6 +24,18 @@ func ErrorResponse(w http.ResponseWriter, statusCode int, err error) { ErrorResponse(w, 1, err) } + switch statusCode { + case 1: + ErrorStatus(w) + break + case 2: + w.WriteHeader(http.StatusUnauthorized) + break + default: + ErrorStatus(w) + break + } + w.Header().Set("Content-Type", "application/json") w.Write(responseText) }