add base handler and refactor H

This commit is contained in:
2025-10-28 21:38:58 +01:00
parent fb4d31afba
commit c7024d7f4e
7 changed files with 118 additions and 22 deletions
+16
View File
@@ -0,0 +1,16 @@
package domains
import (
"encoding/json"
"net/http"
)
type (
BaseHandler struct{}
)
func (bh *BaseHandler) ToJSON(w http.ResponseWriter, statusCode int, data any) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(statusCode)
json.NewEncoder(w).Encode(data)
}