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.
15 lines
292 B
15 lines
292 B
package responses
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
// JSON sends a JSON payload as response.
|
|
func JSON(w http.ResponseWriter, statusCode int, v interface{}) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(statusCode)
|
|
|
|
enc := json.NewEncoder(w)
|
|
enc.Encode(v)
|
|
}
|
|
|