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.
13 lines
254 B
13 lines
254 B
2 years ago
|
package Utils
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func RespondJSON(data interface{}, code int, writer http.ResponseWriter) {
|
||
|
writer.Header().Add("Content-type", "application/json")
|
||
|
writer.WriteHeader(code)
|
||
|
json.NewEncoder(writer).Encode(data)
|
||
|
}
|