17 lines
285 B
Go
17 lines
285 B
Go
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)
|
|
}
|