protohttp

package
v0.5.1-0...-faa3f61 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIfResponseHasError

func CheckIfResponseHasError(rsp *http.Response) error

CheckIfResponseHasError checks an HTTP Response for errors and returns error information with the following precedence: 1. "linkerd-error" header, with protobuf-encoded apiError 2. non-200 Status Code, with Kubernetes StatusError 3. non-200 Status Code

func FromByteStreamToProtocolBuffers

func FromByteStreamToProtocolBuffers(byteStreamContainingMessage *bufio.Reader, out proto.Message) error

FromByteStreamToProtocolBuffers converts a byte stream to a protobuf message.

func HTTPRequestToProto

func HTTPRequestToProto(req *http.Request, protoRequestOut proto.Message) error

HTTPRequestToProto converts an HTTP Request to a protobuf request.

func SerializeAsPayload

func SerializeAsPayload(messageContentsInBytes []byte) []byte

SerializeAsPayload appends a 4-byte length in front of a byte slice.

func WriteErrorToHTTPResponse

func WriteErrorToHTTPResponse(w http.ResponseWriter, errorObtained error)

WriteErrorToHTTPResponse writes a protobuf-encoded error to an HTTP Response.

func WriteProtoToHTTPResponse

func WriteProtoToHTTPResponse(w http.ResponseWriter, msg proto.Message) error

WriteProtoToHTTPResponse writes a protobuf-encoded message to an HTTP Response.

Types

type FlushableResponseWriter

type FlushableResponseWriter interface {
	http.ResponseWriter
	http.Flusher
}

FlushableResponseWriter wraps a ResponseWriter for use in streaming responses

func NewStreamingWriter

func NewStreamingWriter(w http.ResponseWriter) (FlushableResponseWriter, error)

NewStreamingWriter takes a ResponseWriter and returns it wrapped in a FlushableResponseWriter.

type HTTPError

type HTTPError struct {
	Code         int
	WrappedError error
}

HTTPError is an error which indicates the HTTP response contained an error

func (HTTPError) Error

func (e HTTPError) Error() string

Error satisfies the error interface for HTTPError.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL