|
@@ -1,7 +1,6 @@
|
|
|
package httputils
|
|
|
|
|
|
import (
|
|
|
- "encoding/json"
|
|
|
"fmt"
|
|
|
"io"
|
|
|
"net/http"
|
|
@@ -77,15 +76,6 @@ func ParseForm(r *http.Request) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-// WriteJSON writes the value v to the http response stream as json with standard json encoding.
|
|
|
-func WriteJSON(w http.ResponseWriter, code int, v interface{}) error {
|
|
|
- w.Header().Set("Content-Type", "application/json")
|
|
|
- w.WriteHeader(code)
|
|
|
- enc := json.NewEncoder(w)
|
|
|
- enc.SetEscapeHTML(false)
|
|
|
- return enc.Encode(v)
|
|
|
-}
|
|
|
-
|
|
|
// VersionFromContext returns an API version from the context using APIVersionKey.
|
|
|
// It panics if the context value does not have version.Version type.
|
|
|
func VersionFromContext(ctx context.Context) (ver string) {
|