server

package
v0.0.0-...-bf4e6ac Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DoNotLogErrorHeaderKey is a header name used for marking non-loggable errors. More precisely, if an HTTP response
	// has a status code 5xx, and contains a header with key DoNotLogErrorHeaderKey and any values, the generated error
	// will be marked as non-loggable.
	DoNotLogErrorHeaderKey = http.CanonicalHeaderKey("X-DoNotLogError")

	// ErrorMessageHeaderKey is a header name for header that contains error message that should be used when Server.Handle
	// (httpgrpc.HTTP/Handle implementation) decides to return the response as an error, using status.ErrorProto.
	// Normally Server.Handle would use entire response body as a error message, but Message field of rcp.Status object
	// is a string, and if body contains non-utf8 bytes, marshalling of this object will fail.
	ErrorMessageHeaderKey = http.CanonicalHeaderKey("X-ErrorMessage")
)

Functions

func IsHandledByHttpgrpcServer

func IsHandledByHttpgrpcServer(ctx context.Context) bool

IsHandledByHttpgrpcServer returns true if context is associated with HTTP request that was initiated by Server.Handle, which is an implementation of httpgrpc.HTTP/Handle gRPC method.

func ParseURL

func ParseURL(unparsed string) (string, error)

ParseURL deals with direct:// style URLs, as well as kubernetes:// urls. For backwards compatibility it treats URLs without schemes as kubernetes://.

func WithReturn4XXErrors

func WithReturn4XXErrors(s *Server)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a http.Handler that forwards the request over gRPC.

func NewClient

func NewClient(address string) (*Client, error)

NewClient makes a new Client, given a kubernetes service address.

func (*Client) ServeHTTP

func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler

type Option

type Option func(*Server)

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements HTTPServer. HTTPServer is a generated interface that gRPC servers must implement.

func NewServer

func NewServer(handler http.Handler, opts ...Option) *Server

NewServer makes a new Server.

func (Server) Handle

Handle implements HTTPServer.

Jump to

Keyboard shortcuts

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