router/send_json.go (view raw)
1 2 3 4 5 6 7 8 9 10 11 12
package router import ( "encoding/json" "net/http" ) func SendResponse(w http.ResponseWriter, status int, response interface{}) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(status) json.NewEncoder(w).Encode(response) }