This commit is contained in:
2025-07-20 21:22:20 -04:00
parent 349f7fad57
commit 62336753c6
7 changed files with 165 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
package testfunc
import (
"encoding/json"
"net/http"
"git.dubyatp.xyz/orphanage/client/httputil"
)
type TestResponse struct {
APIVersion string `json:"apiVersion"`
TestMessage string `json:"testMessage"`
}
func (m TestResponse) MarshalJSON() ([]byte, error) {
type OrderedTestResponse struct {
APIVersion string `json:"apiVersion"`
TestMessage string `json:"testMessage"`
}
ordered := OrderedTestResponse{
APIVersion: m.APIVersion,
TestMessage: m.TestMessage,
}
return json.Marshal(ordered)
}
func HelloWorldJSON(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
resp := TestResponse{
APIVersion: "v1",
TestMessage: "this is a test owo",
}
httputil.WriteJSON(w, http.StatusOK, resp)
})
}