Documentation
¶
Index ¶
- Constants
- Variables
- func BuildRequest(ctx context.Context, method string, urlString string, parameters url.Values, ...) (*http.Request, error)
- func CheckResponseIsSuccessful(req *http.Request, resp *http.Response) error
- func CreateDefaultHttpClient() *http.Client
- func CreateHttpClient(timeout time.Duration) *http.Client
- func CreateTlsClientConfig(ctx context.Context, caCertPath string, clientCertPath string, ...) (*tls.Config, error)
- func FileServer(root string, prefix string) http.Handler
- func IsIgnoredSentryError(err error) bool
- func IsRetryError(err error) bool
- func NewBackgroundRunHandler(ctx context.Context, runFunc run.Func) http.Handler
- func NewErrorHandler(withError WithError) http.Handler
- func NewPrintHandler(format string, a ...any) http.Handler
- func NewProxy(transport http.RoundTripper, apiUrl *url.URL, ...) http.Handler
- func NewRoundTripperBasicAuth(roundTripper RoundTripper, username string, password string) http.RoundTripper
- func NewRoundTripperHeader(roundTripper http.RoundTripper, header http.Header) http.RoundTripper
- func NewRoundTripperLog(tripper http.RoundTripper) http.RoundTripper
- func NewRoundTripperRateLimit(ctx context.Context, tripper http.RoundTripper, maxRequestPerInterval int64, ...) http.RoundTripper
- func NewRoundTripperRemovePathPrefix(roundTripper http.RoundTripper, prefix string) http.RoundTripper
- func NewRoundTripperRetry(roundTripper http.RoundTripper, retryLimit int, retryDelay time.Duration) http.RoundTripper
- func NewRoundTripperRetryWithSkipStatus(roundTripper http.RoundTripper, retryLimit int, retryDelay time.Duration, ...) http.RoundTripper
- func NewServer(addr string, router http.Handler) run.Func
- func NewServerTLS(addr string, router http.Handler, serverCertPath string, serverKeyPath string) run.Func
- func NewServerWithPort(port int, router http.Handler) run.Func
- func NewSkipErrorWriter(writer io.Writer) io.Writer
- func NewUpdateErrorHandler(db libkv.DB, withErrorTx WithErrorTx) http.Handler
- func NewViewErrorHandler(db libkv.DB, withErrorTx WithErrorTx) http.Handler
- func RegisterPprof(router *mux.Router)
- func WriteAndGlog(w io.Writer, format string, a ...any) (n int, err error)
- type CheckRedirect
- type DialFunc
- type ErrorWithStatusCode
- type HasTemporaryError
- type HasTimeoutError
- type HttpClientBuilder
- type JsonHandler
- type JsonHandlerFunc
- type JsonHandlerTx
- type JsonHandlerTxFunc
- type Proxy
- type ProxyErrorHandler
- type ProxyErrorHandlerFunc
- type RequestFailedError
- type RoundTripper
- type RoundTripperFunc
- type WithError
- func NewCpuProfileStartHandler() WithError
- func NewCpuProfileStopHandler() WithError
- func NewFileDownloader(path string) WithError
- func NewJsonHandler(jsonHandler JsonHandler) WithError
- func NewJsonHandlerUpdateTx(db libkv.DB, jsonHandler JsonHandlerTx) WithError
- func NewJsonHandlerViewTx(db libkv.DB, jsonHandler JsonHandlerTx) WithError
- func NewMemoryProfileHandler() WithError
- func NewProfilingStart() WithError
- func NewProfilingStop() WithError
- type WithErrorFunc
- type WithErrorTx
- type WithErrorTxFunc
Constants ¶
View Source
const ( ApplicationJsonContentType = "application/json" TextHtml = "text/html" )
View Source
const (
ContentTypeHeaderName = "Content-Type"
)
View Source
const PreventRetryHeaderName = "X-Prevent-Retry"
Variables ¶
View Source
var NotFound = stderrors.New("not found")
Functions ¶
func BuildRequest ¶
func CreateDefaultHttpClient ¶
func CreateTlsClientConfig ¶
func IsIgnoredSentryError ¶
func IsRetryError ¶
func NewBackgroundRunHandler ¶
func NewErrorHandler ¶
func NewProxy ¶
func NewProxy( transport http.RoundTripper, apiUrl *url.URL, proxyErrorHandler ProxyErrorHandler, ) http.Handler
func NewRoundTripperBasicAuth ¶
func NewRoundTripperBasicAuth( roundTripper RoundTripper, username string, password string, ) http.RoundTripper
func NewRoundTripperHeader ¶
func NewRoundTripperHeader( roundTripper http.RoundTripper, header http.Header, ) http.RoundTripper
func NewRoundTripperLog ¶
func NewRoundTripperLog(tripper http.RoundTripper) http.RoundTripper
func NewRoundTripperRateLimit ¶
func NewRoundTripperRateLimit( ctx context.Context, tripper http.RoundTripper, maxRequestPerInterval int64, intervalDurarion time.Duration, logSamplerFactory log.SamplerFactory, ) http.RoundTripper
func NewRoundTripperRemovePathPrefix ¶
func NewRoundTripperRemovePathPrefix( roundTripper http.RoundTripper, prefix string, ) http.RoundTripper
func NewRoundTripperRetry ¶
func NewRoundTripperRetry( roundTripper http.RoundTripper, retryLimit int, retryDelay time.Duration, ) http.RoundTripper
NewRoundTripperRetry wraps a given RoundTripper and retry the httpRequest with a delay between.
func NewRoundTripperRetryWithSkipStatus ¶ added in v1.8.1
func NewRoundTripperRetryWithSkipStatus( roundTripper http.RoundTripper, retryLimit int, retryDelay time.Duration, skipStatusCodes []int, ) http.RoundTripper
func NewServerTLS ¶
func NewUpdateErrorHandler ¶ added in v1.8.0
func NewUpdateErrorHandler(db libkv.DB, withErrorTx WithErrorTx) http.Handler
func NewViewErrorHandler ¶ added in v1.8.0
func NewViewErrorHandler(db libkv.DB, withErrorTx WithErrorTx) http.Handler
func RegisterPprof ¶
RegisterPprof register pprof http endpoint to gorilla mux https://www.codereliant.io/memory-leaks-with-pprof/ kubectl -n erpnext port-forward service/hubspot-resource-exporter 9090:9090 go tool pprof -alloc_space http://localhost:9090/debug/pprof/heap > web or go tool pprof -http=127.0.0.1:16666 -alloc_space http://localhost:9090/debug/pprof/heap
Types ¶
type ErrorWithStatusCode ¶ added in v1.9.0
func WrapWithStatusCode ¶ added in v1.9.0
func WrapWithStatusCode(err error, code int) ErrorWithStatusCode
WrapWithStatusCode wraps a existing error with statusCode used by ErrorHandler
type HasTemporaryError ¶
type HasTemporaryError interface {
Temporary() bool
}
type HasTimeoutError ¶
type HasTimeoutError interface {
Timeout() bool
}
type HttpClientBuilder ¶
type HttpClientBuilder interface {
WithRetry(retryLimit int, retryDelay time.Duration) HttpClientBuilder
WithoutRetry() HttpClientBuilder
WithProxy() HttpClientBuilder
WithoutProxy() HttpClientBuilder
WithRedirects() HttpClientBuilder
WithoutRedirects() HttpClientBuilder
WithTimeout(timeout time.Duration) HttpClientBuilder
WithDialFunc(dialFunc DialFunc) HttpClientBuilder
WithInsecureSkipVerify(insecureSkipVerify bool) HttpClientBuilder
WithClientCert(caCertPath string, clientCertPath string, clientKeyPath string) HttpClientBuilder
Build(ctx context.Context) (*http.Client, error)
BuildRoundTripper(ctx context.Context) (http.RoundTripper, error)
}
func NewClientBuilder ¶
func NewClientBuilder() HttpClientBuilder
type JsonHandler ¶
type JsonHandlerFunc ¶
type JsonHandlerTx ¶ added in v1.8.0
type JsonHandlerTxFunc ¶ added in v1.8.0
type ProxyErrorHandler ¶
type ProxyErrorHandler interface {
HandleError(resp http.ResponseWriter, req *http.Request, err error)
}
func NewSentryProxyErrorHandler ¶
func NewSentryProxyErrorHandler(sentryClient libsentry.Client) ProxyErrorHandler
type ProxyErrorHandlerFunc ¶
type ProxyErrorHandlerFunc func(resp http.ResponseWriter, req *http.Request, err error)
func (ProxyErrorHandlerFunc) HandleError ¶
func (p ProxyErrorHandlerFunc) HandleError(resp http.ResponseWriter, req *http.Request, err error)
type RequestFailedError ¶
func (RequestFailedError) Error ¶
func (r RequestFailedError) Error() string
type RoundTripper ¶
type RoundTripper interface {
http.RoundTripper
}
func CreateDefaultRoundTripper ¶
func CreateDefaultRoundTripper() RoundTripper
type RoundTripperFunc ¶
type WithError ¶
type WithError interface {
ServeHTTP(ctx context.Context, resp http.ResponseWriter, req *http.Request) error
}
func NewCpuProfileStartHandler ¶
func NewCpuProfileStartHandler() WithError
func NewCpuProfileStopHandler ¶
func NewCpuProfileStopHandler() WithError
func NewFileDownloader ¶
func NewJsonHandler ¶
func NewJsonHandler(jsonHandler JsonHandler) WithError
func NewJsonHandlerUpdateTx ¶ added in v1.8.0
func NewJsonHandlerUpdateTx(db libkv.DB, jsonHandler JsonHandlerTx) WithError
func NewJsonHandlerViewTx ¶ added in v1.8.0
func NewJsonHandlerViewTx(db libkv.DB, jsonHandler JsonHandlerTx) WithError
func NewMemoryProfileHandler ¶
func NewMemoryProfileHandler() WithError
func NewProfilingStart ¶
func NewProfilingStart() WithError
func NewProfilingStop ¶
func NewProfilingStop() WithError
type WithErrorFunc ¶
func (WithErrorFunc) ServeHTTP ¶
func (w WithErrorFunc) ServeHTTP(ctx context.Context, resp http.ResponseWriter, req *http.Request) error
type WithErrorTx ¶ added in v1.8.0
Source Files
¶
- http_background-handler.go
- http_build-request.go
- http_check-response.go
- http_client-builder.go
- http_client.go
- http_content-types.go
- http_cpu-profile-handler.go
- http_error-handler-tx.go
- http_error-handler.go
- http_errors.go
- http_file-downloader-handler.go
- http_fileserver.go
- http_headers.go
- http_json-handler-tx.go
- http_json-handler.go
- http_memory-profile-handler.go
- http_pprof-handler.go
- http_pprof.go
- http_print-handler.go
- http_proxy-error-handler-sentry.go
- http_proxy-error-handler.go
- http_proxy.go
- http_roundtripper-basic-auth.go
- http_roundtripper-default.go
- http_roundtripper-func.go
- http_roundtripper-header.go
- http_roundtripper-log.go
- http_roundtripper-ratelimit.go
- http_roundtripper-remove-path-prefix.go
- http_roundtripper-retry.go
- http_roundtripper.go
- http_server.go
- http_with-error-tx.go
- http_with-error.go
- http_write-and-glog.go
Click to show internal directories.
Click to hide internal directories.