api

package
v0.0.0-...-4d7012a Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIUrl        = "https://spider.infinitybots.gg"
	StagingAPIUrl = "https://spider-staging.infinitybots.gg"
)

Variables

View Source
var ClientURL = APIUrl

Functions

This section is empty.

Types

type ClientRequest

type ClientRequest struct {
	// contains filtered or unexported fields
}

A request to the API

func NewReq

func NewReq() ClientRequest

Creates a new request

func (ClientRequest) Auth

func (r ClientRequest) Auth(token string) ClientRequest

Sets the authorization header

func (ClientRequest) Delete

func (r ClientRequest) Delete(path string) ClientRequest

Sets the method to DELETE

func (ClientRequest) Do

func (r ClientRequest) Do() (*ClientResponse, error)

Executes the request

func (ClientRequest) Get

func (r ClientRequest) Get(path string) ClientRequest

Sets the method to GET

func (ClientRequest) Head

func (r ClientRequest) Head(path string) ClientRequest

Sets the method to HEAD

func (ClientRequest) Header

func (r ClientRequest) Header(key string, value string) ClientRequest

Sets a header

func (ClientRequest) Json

func (r ClientRequest) Json(json any) ClientRequest

Sets the body of the request

func (ClientRequest) Method

func (r ClientRequest) Method(method string) ClientRequest

Sets the method of the request

func (ClientRequest) Patch

func (r ClientRequest) Patch(path string) ClientRequest

Sets the method to PATCH

func (ClientRequest) Path

func (r ClientRequest) Path(path string) ClientRequest

Sets the path of the request

func (ClientRequest) Post

func (r ClientRequest) Post(path string) ClientRequest

Sets the method to POST

func (ClientRequest) Put

func (r ClientRequest) Put(path string) ClientRequest

Sets the method to PUT

type ClientResponse

type ClientResponse struct {
	Request  *http.Request
	Response *http.Response
}

A response from the API

func (ClientResponse) Body

func (c ClientResponse) Body() ([]byte, error)

Returns the response body

func (ClientResponse) BodyOk

func (c ClientResponse) BodyOk() ([]byte, error)

Returns the response body if the response is OK otherwise returns error

func (ClientResponse) IsMaint

func (c ClientResponse) IsMaint() bool

Returns true if the response is a maintenance response (502, 503, 408)

func (ClientResponse) Json

func (c ClientResponse) Json(v any) error

Unmarshals the response body into the given struct

func (ClientResponse) JsonOk

func (c ClientResponse) JsonOk(v any) error

Unmarshals response body if response is OK otherwise returns error

func (ClientResponse) RetryAfter

func (c ClientResponse) RetryAfter() string

Returns the retry after header. Is a string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳