init: first steps

This commit is contained in:
2025-07-20 23:50:47 +03:00
commit 5f26ad6941
25 changed files with 1134 additions and 0 deletions

19
pkg/http/response.go Normal file
View File

@@ -0,0 +1,19 @@
package http
import (
"encoding/json"
"net/http"
)
func JSON(w http.ResponseWriter, i any, httpCode int) error {
response, err := json.Marshal(i)
if err != nil {
return err
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(httpCode)
_, err = w.Write(response)
return err
}