You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
287 B

package utils
2 years ago
import (
"encoding/json"
"net/http"
)
type Msg struct {
Msg string
}
2 years ago
func RespondJSON(data interface{}, code int, writer http.ResponseWriter) {
writer.Header().Add("Content-type", "application/json")
writer.WriteHeader(code)
json.NewEncoder(writer).Encode(data)
}