httpx

package
v0.0.0-...-352bf0c Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Endpoint

func Endpoint(name string, handler http.HandlerFunc) http.Handler

func EndpointWithAsyncTask

func EndpointWithAsyncTask()

- with async after response - with body available after response Allows body to be read after response is sent

func EndpointWithAuthentication

func EndpointWithAuthentication()

- with authentication

func EndpointWithCustomMiddlewares

func EndpointWithCustomMiddlewares(name string, handler http.HandlerFunc, pre, post []http.HandlerFunc) http.Handler

- with custom middleware

func EndpointWithErrorHandler

func EndpointWithErrorHandler()

- with error handling accordingly to API

func EndpointWithProxy

func EndpointWithProxy()

- with proxy

func EndpointWithRateLimit

func EndpointWithRateLimit()

- with rate limit

func EndpointWithRedirect

func EndpointWithRedirect()

- with redirect

func JSONEndpoint

func JSONEndpoint(name string, handler http.HandlerFunc) http.Handler

Types

type ResponseRecorder

type ResponseRecorder struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

ResponseRecorder wraps a http.ResponseWriter to record its status code before the response is written. TODO: Explain why it does not matter to lose the rest of the default interfaces.

func NewResponseRecorder

func NewResponseRecorder(w http.ResponseWriter) *ResponseRecorder

func (*ResponseRecorder) GetBody

func (rw *ResponseRecorder) GetBody() []byte

func (*ResponseRecorder) GetStatusCode

func (rw *ResponseRecorder) GetStatusCode() int

func (*ResponseRecorder) Header

func (rw *ResponseRecorder) Header() http.Header

func (*ResponseRecorder) Write

func (rw *ResponseRecorder) Write(p []byte) (n int, err error)

func (*ResponseRecorder) WriteHeader

func (rw *ResponseRecorder) WriteHeader(statusCode int)

type Server

type Server struct {
	*http.Server
}

func NewServer

func NewServer(addr string, handler http.Handler) *Server

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Jump to

Keyboard shortcuts

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