Documentation ¶
Index ¶
- func Connect(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func Delete(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func DeleteWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func Get(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func GetBuffer() *bytes.Buffer
- func GetWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func Head(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func HeadWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func OptionWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func Options(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func Patch(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func PatchWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func Post(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func PostWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func Put(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func PutBuffer(b *bytes.Buffer)
- func PutWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func Request(method, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func RequestWithContext(ctx context.Context, method, path string, params Params, ...) (*http.Response, []byte, error)
- func ToString(v any) (string, error)
- func Trace(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func TraceWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- type AfterRequestHook
- type Any
- type BeforeRequestHook
- type Option
- func WithAfterHooks(hooks ...AfterRequestHook) Option
- func WithBeforeHooks(hooks ...BeforeRequestHook) Option
- func WithClient(client *http.Client) Option
- func WithGlobalHeader(header Any) Option
- func WithGlobalTimeout(t time.Duration) Option
- func WithTransport(t http.RoundTripper) Option
- func WithUserAgent(name string) Option
- type Params
- type Session
- func (s *Session) Apply(opts ...Option)
- func (s *Session) Connect(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) ConnectWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) Delete(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) DeleteWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) Get(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) GetWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) Head(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) HeadWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) OptionWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) Options(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) Patch(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) PatchWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) Post(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) PostWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) Prepare(ctx context.Context, method, path string, params Params, buff *bytes.Buffer) (*http.Request, error)
- func (s *Session) Put(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) PutWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) Request(method, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) RequestWithContext(ctx context.Context, method, path string, params Params, ...) (*http.Response, []byte, error)
- func (s *Session) Send(req *http.Request, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) Trace(path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- func (s *Session) TraceWithContext(ctx context.Context, path string, params Params, unmarshaller Unmarshaller) (*http.Response, []byte, error)
- type Unmarshaller
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteWithContext ¶ added in v0.1.5
func GetWithContext ¶ added in v0.1.5
func HeadWithContext ¶ added in v0.1.5
func OptionWithContext ¶ added in v0.1.5
func PatchWithContext ¶ added in v0.1.5
func PostWithContext ¶ added in v0.1.5
func PutWithContext ¶ added in v0.1.5
func RequestWithContext ¶ added in v0.1.5
Types ¶
type AfterRequestHook ¶ added in v0.3.0
AfterRequestHook 会在完成`Client.Do(*http.Request)`后立即调用
func LogResponse ¶ added in v0.3.0
func LogResponse(logger *slog.Logger) AfterRequestHook
func StdLogResponse ¶ added in v0.3.0
func StdLogResponse(logger *log.Logger) AfterRequestHook
type BeforeRequestHook ¶ added in v0.3.0
BeforeRequestHook 会在调用`Client.Do(*http.Request)`前调用,此时已经完成了parama的自动装填
func LogRequest ¶ added in v0.3.0
func LogRequest(logger *slog.Logger) BeforeRequestHook
func StdLogRequest ¶ added in v0.3.0
func StdLogRequest(logger *log.Logger) BeforeRequestHook
type Option ¶
type Option func(*Session)
func WithAfterHooks ¶ added in v0.3.0
func WithAfterHooks(hooks ...AfterRequestHook) Option
func WithBeforeHooks ¶ added in v0.3.0
func WithBeforeHooks(hooks ...BeforeRequestHook) Option
func WithClient ¶ added in v0.2.0
func WithGlobalHeader ¶ added in v0.2.0
func WithGlobalTimeout ¶ added in v0.2.0
func WithTransport ¶ added in v0.2.2
func WithTransport(t http.RoundTripper) Option
func WithUserAgent ¶ added in v0.2.0
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func (*Session) ConnectWithContext ¶ added in v0.1.5
func (*Session) DeleteWithContext ¶ added in v0.1.5
func (*Session) GetWithContext ¶ added in v0.1.5
func (*Session) HeadWithContext ¶ added in v0.1.5
func (*Session) OptionWithContext ¶ added in v0.1.5
func (*Session) PatchWithContext ¶ added in v0.1.5
func (*Session) PostWithContext ¶ added in v0.1.5
func (*Session) PutWithContext ¶ added in v0.1.5
func (*Session) RequestWithContext ¶ added in v0.1.5
type Unmarshaller ¶ added in v0.3.0
ResponseRender 用于对response的反序列化
func UnmarlXML ¶ added in v0.3.0
func UnmarlXML(v any) Unmarshaller
func UnmarshalJSON ¶ added in v0.3.0
func UnmarshalJSON(v any) Unmarshaller
Click to show internal directories.
Click to hide internal directories.