apiserverk8s.io/apiserver/pkg/endpoints/handlers/responsewriters Index | Files

package responsewriters

import "k8s.io/apiserver/pkg/endpoints/handlers/responsewriters"

Package responsewriters containers helpers to write responses in HTTP handlers.

Index

Functions

func ErrorNegotiated

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

func ErrorToAPIStatus(err error) *metav1.Status

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 ForbiddenStatusError

func ForbiddenStatusError(attributes authorizer.Attributes, reason string) *apierrors.StatusError

func InternalError

func InternalError(w http.ResponseWriter, req *http.Request, err error)

InternalError renders a simple internal error

func SerializeObject

func SerializeObject(mediaType string, encoder runtime.Encoder, hw 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. This method will perform optional content compression if requested by a client and the feature gate for APIResponseCompression is enabled.

func StreamObject

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 WriteObjectNegotiated

func WriteObjectNegotiated(s runtime.NegotiatedSerializer, restrictions negotiation.EndpointRestrictions, gv schema.GroupVersion, w http.ResponseWriter, req *http.Request, statusCode int, object runtime.Object, listGVKInContentType bool)

WriteObjectNegotiated renders an object in the content type negotiated by the client.

func WriteRawJSON

func WriteRawJSON(statusCode int, object interface{}, w http.ResponseWriter)

WriteRawJSON writes a non-API object in JSON.

Source Files

doc.go errors.go status.go writers.go

Version
v0.33.0 (latest)
Published
Apr 23, 2025
Platform
linux/amd64
Imports
28 packages
Last checked
2 hours ago

Tools for package owners.