flies

package
v0.0.0-...-7245f98 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveOptions

func ResolveOptions(opts ...RequestOption) []httpx.RequestOption

ResolveOptions resolves one or more RequestOption to httpx.RequestOption.

func Unmarshal

func Unmarshal(body io.Reader, typ interface{}) error

Unmarshal unmarshals the body to the interface, panicking if `typ` is not a pointer.

Types

type Options

type Options struct {
	Token  string
	Body   io.Reader
	Reason string
	Query  url.Values
}

Options represents different optional options that can be set on a request.

type RequestOption

type RequestOption func(*Options)

RequestOption configures a single request.

func WithPayload

func WithPayload(b []byte) RequestOption

WithPayload sets the body of a request.

func WithQuery

func WithQuery(q url.Values) RequestOption

WithQuery adds the given query values to a request.

func WithReader

func WithReader(r io.Reader) RequestOption

WithReader sets the body of a request with the given io.Reader.

func WithReason

func WithReason(reason string) RequestOption

WithReason sets the X-Audit-Log-Reason on a request.

func WithToken

func WithToken(t string) RequestOption

WithToken overrides the default token for a request.

type RestClient

type RestClient interface {
	// Do should create a request from the given options, perform it, check for errors, then
	// finally return the response.
	Do(ctx context.Context, method, uri string, opts ...RequestOption) (*http.Response, error)

	// DoFromRequest should perform the same as Do, except with a given Request object.
	DoFromRequest(context.Context, *http.Request) (*http.Response, error)

	// NewRequest should create a Request object given the parameters to use with DoFromRequest.
	NewRequest(ctx context.Context, method, uri string, opt ...RequestOption) (*http.Request, error)
}

RestClient represents a REST Client that is responsible for performing requests against Discord's API.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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