|
@@ -40,10 +40,10 @@ type Message struct {
|
|
|
Cookies []*http.Cookie
|
|
|
}
|
|
|
|
|
|
-func header(w http.ResponseWriter, contentType string) {
|
|
|
- w.Header().Set(`Content-Type`, contentType)
|
|
|
- w.Header().Set(`X-Powered-By`, LibName+`/`+LibVersion)
|
|
|
- w.WriteHeader(http.StatusOK)
|
|
|
+func header(w io.Writer, contentType string) {
|
|
|
+ w.(http.ResponseWriter).Header().Set(`Content-Type`, contentType)
|
|
|
+ w.(http.ResponseWriter).Header().Set(`X-Powered-By`, LibName+`/`+LibVersion)
|
|
|
+ w.(http.ResponseWriter).WriteHeader(http.StatusOK)
|
|
|
}
|
|
|
|
|
|
|
|
@@ -61,7 +61,7 @@ func GetRealIP(req *http.Request) (ip string) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-func WriteJSON(w http.ResponseWriter, response interface{}) error {
|
|
|
+func WriteJSON(w io.Writer, response interface{}) error {
|
|
|
header(w, `application/json; charset=utf-8`)
|
|
|
return json.NewEncoder(w).Encode(response)
|
|
|
}
|