net

package
v1.0.0-beta.11 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTimeout = time.Duration(20000) * time.Millisecond
	Logger         = logger.HcLog().Named("supabase.client.net")
)
View Source
var GetClient func() Client = func() Client {
	return &http.Client{
		Timeout: DefaultTimeout,
	}
}

Functions

func Delete

func Delete[T any](url string, rawBody []byte, timeout time.Duration, reqInterceptor RequestInterceptor, resInterceptor ResponseInterceptor) (res T, err error)

func Get

func Get[T any](url string, timeout time.Duration, reqInterceptor RequestInterceptor, resInterceptor ResponseInterceptor) (res T, err error)

func Patch

func Patch[T any](url string, rawBody []byte, timeout time.Duration, reqInterceptor RequestInterceptor, resInterceptor ResponseInterceptor) (res T, err error)

func Post

func Post[T any](url string, rawBody []byte, timeout time.Duration, reqInterceptor RequestInterceptor, resInterceptor ResponseInterceptor) (res T, err error)

func Put

func Put[T any](url string, rawBody []byte, timeout time.Duration, reqInterceptor RequestInterceptor, resInterceptor ResponseInterceptor) (res T, err error)

func SendRequest

func SendRequest(method string, url string, body []byte, timeout time.Duration, reqInterceptor RequestInterceptor, resInterceptor ResponseInterceptor) (rawBody []byte, err error)

Types

type Client

type Client interface {
	Do(req *http.Request) (*http.Response, error)
}

type DefaultResponse

type DefaultResponse struct {
	Message string `json:"message"`
}

type ReqError

type ReqError struct {
	Message string
	Body    []byte
}

func (ReqError) Error

func (s ReqError) Error() string

type RequestInterceptor

type RequestInterceptor func(req *http.Request) error

type ResponseInterceptor

type ResponseInterceptor func(resp *http.Response) error

Jump to

Keyboard shortcuts

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