Documentation ¶
Overview ¶
Package responsewriters containers helpers to write responses in HTTP handlers.
Index ¶
- func ErrorNegotiated(err error, s runtime.NegotiatedSerializer, gv schema.GroupVersion, ...) int
- func ErrorToAPIStatus(err error) *metav1.Status
- func Forbidden(ctx context.Context, attributes authorizer.Attributes, w http.ResponseWriter, ...)
- func InternalError(w http.ResponseWriter, req *http.Request, err error)
- func SerializeObject(mediaType string, encoder runtime.Encoder, innerW http.ResponseWriter, ...)
- func StreamObject(statusCode int, gv schema.GroupVersion, s runtime.NegotiatedSerializer, ...)
- func WriteObject(statusCode int, gv schema.GroupVersion, s runtime.NegotiatedSerializer, ...)
- func WriteObjectNegotiated(s runtime.NegotiatedSerializer, gv schema.GroupVersion, w http.ResponseWriter, ...)
- func WriteRawJSON(statusCode int, object interface{}, w http.ResponseWriter)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorNegotiated ¶
func ErrorNegotiated(err error, s runtime.NegotiatedSerializer, gv schema.GroupVersion, w http.ResponseWriter, req *http.Request) int
ErrorNegotiated renders an error to the response. Returns the HTTP status code of the error. The context is optional and may be nil.
func ErrorToAPIStatus ¶ added in v1.7.0
ErrorToAPIStatus converts an error to an metav1.Status object.
func Forbidden ¶
func Forbidden(ctx context.Context, attributes authorizer.Attributes, w http.ResponseWriter, req *http.Request, reason string, s runtime.NegotiatedSerializer)
Forbidden renders a simple forbidden error
func InternalError ¶
func InternalError(w http.ResponseWriter, req *http.Request, err error)
InternalError renders a simple internal error
func SerializeObject ¶ added in v1.7.0
func SerializeObject(mediaType string, encoder runtime.Encoder, innerW http.ResponseWriter, req *http.Request, statusCode int, object runtime.Object)
SerializeObject renders an object in the content type negotiated by the client using the provided encoder. The context is optional and can be nil.
func StreamObject ¶ added in v1.7.0
func StreamObject(statusCode int, gv schema.GroupVersion, s runtime.NegotiatedSerializer, stream rest.ResourceStreamer, w http.ResponseWriter, req *http.Request)
StreamObject performs input stream negotiation from a ResourceStreamer and writes that to the response. If the client requests a websocket upgrade, negotiate for a websocket reader protocol (because many browser clients cannot easily handle binary streaming protocols).
func WriteObject ¶
func WriteObject(statusCode int, gv schema.GroupVersion, s runtime.NegotiatedSerializer, object runtime.Object, w http.ResponseWriter, req *http.Request)
WriteObject renders a returned runtime.Object to the response as a stream or an encoded object. If the object returned by the response implements rest.ResourceStreamer that interface will be used to render the response. The Accept header and current API version will be passed in, and the output will be copied directly to the response body. If content type is returned it is used, otherwise the content type will be "application/octet-stream". All other objects are sent to standard JSON serialization.
func WriteObjectNegotiated ¶
func WriteObjectNegotiated(s runtime.NegotiatedSerializer, gv schema.GroupVersion, w http.ResponseWriter, req *http.Request, statusCode int, object runtime.Object)
WriteObjectNegotiated renders an object in the content type negotiated by the client. The context is optional and can be nil.
func WriteRawJSON ¶
func WriteRawJSON(statusCode int, object interface{}, w http.ResponseWriter)
WriteRawJSON writes a non-API object in JSON.
Types ¶
This section is empty.