From 3a2cac064f547a2babbbc4d206f57e8579005299 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Tue, 26 Sep 2023 14:22:00 +0900 Subject: [PATCH] initial commits --- ok.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ok.go diff --git a/ok.go b/ok.go new file mode 100644 index 0000000..921e6e9 --- /dev/null +++ b/ok.go @@ -0,0 +1,20 @@ +package mstdn + +import ( + "encoding/json" + "net/http" +) + +func OK(resp http.ResponseWriter, value interface{}) { + if nil == resp { + return + } + + resp.WriteHeader(http.StatusOK) + resp.Header().Add("Content-Type", "application/json; charset=utf-8") + + err := json.NewEncoder(resp).Encode(value) + if nil != err { + // Nothing here. + } +}