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.

20 lines
512 B

package jsend
import (
"encoding/json"
"net/http"
)
// A response denoting a successful request.
// More information about a success response can be found at:
// https://github.com/omniti-labs/jsend
func Success(w http.ResponseWriter, data map[string]interface{}) {
jdata, err := json.Marshal(data)
if err != nil {
jdata = []byte("null")
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write([]byte("{\"status\": \"success\", \"data\": " + string(jdata) + "}"))
}