Documentation ¶
Index ¶
- Constants
- Variables
- func Delete(ctx context.Context, requestURL string, options ...Option) (err error)
- func Get[T any](ctx context.Context, requestURL string, options ...Option) (result T, err error)
- func Header(opts ...HeaderOption) http.Header
- func Modify[T any](ctx context.Context, method string, requestURL string, options ...Option) (val T, err error)
- type AuthType
- type ContentType
- type Error
- type HeaderOption
- type Option
Constants ¶
View Source
const ( Content = "Content-Type" Authorization = "Authorization" )
Variables ¶
View Source
var ( // ErrMethodNotAllowed ... ErrMethodNotAllowed = errors.New("method not allowed") // ErrMarshallerFuncNotFound ... ErrMarshallerFuncNotFound = errors.New("marshaller function not found in map") // ErrUnmarshalerFuncNotFound ... ErrUnmarshalerFuncNotFound = errors.New("unmarshaler function not found in map") )
View Source
var ( // Marshaller maps some basic content types with top level encoding functions from stdlib Marshaller = map[ContentType]func(v any) ([]byte, error){ ApplicationJSON: json.Marshal, ApplicationXML: xml.Marshal, } // Unmarshaler maps some basic content types with top level decoding functions from stdlib Unmarshaler = map[ContentType]func(data []byte, v any) error{ ApplicationJSON: json.Unmarshal, ApplicationXML: xml.Unmarshal, } // DefaultContentType will be used if no content type specified in headers DefaultContentType = ApplicationJSON )
Functions ¶
func Delete ¶
Delete resource from requestedURL with options WithBody, WithHeaders if error occurred T will be zero value
func Get ¶
Get resource T from requestedURL with options: WithBody, WithHeaders if error occurred T will be zero value
func Header ¶
func Header(opts ...HeaderOption) http.Header
Types ¶
type ContentType ¶
type ContentType string
const ( TextPlain ContentType = "text/plain" ApplicationJSON ContentType = "application/json" ApplicationXML ContentType = "application/xml" )
func (ContentType) String ¶
func (t ContentType) String() string
type Error ¶
Error is custom type for displaying information like status and body of the response message
type HeaderOption ¶
func With ¶
func With(name string, value ...string) HeaderOption
func WithAuth ¶
func WithAuth(auth AuthType, token string) HeaderOption
func WithContent ¶
func WithContent(value ContentType) HeaderOption
func WithHeader ¶
func WithHeader(header http.Header) HeaderOption
Click to show internal directories.
Click to hide internal directories.