Documentation ¶
Index ¶
- Constants
- Variables
- func SetKey(k string)
- func ShortenURL(ctx context.Context, url string) (shortened string, err error)
- func ShortenURLs(ctx context.Context, urls []string) (shortened []string, err error)
- type Client
- func (o *Client) ShortenURL(ctx context.Context, u string) (shortened string, err error)
- func (o *Client) ShortenURLs(ctx context.Context, urls []string) (shortened []string, err error)
- func (o *Client) UploadFile(ctx context.Context, r NamedReader) (response *Response, err error)
- func (o *Client) UploadFiles(ctx context.Context, rs []NamedReader) (response *Response, err error)
- type ErrFileTooBig
- type ErrTooManyFiles
- type ErrUploadFailed
- type File
- type NamedReader
- type Response
Constants ¶
const APIRoot = "https://api.awau.moe"
APIRoot defines base url for the service's API endpoints
const FileCountLimit = 3
FileCountLimit defines a set limit of number of files to allow for pre-flight check before uploading the files
const FileUploadLimit = 83886080
FileUploadLimit defines a set limit for pre-flight check before uploading files
Variables ¶
var ( // APIFileUploadURL to send POSTs with files to APIFileUploadURL = APIRoot + "/upload/pomf" // APIShortenURL to send GETs with urls to APIShortenURL = APIRoot + "/shorten/polr" // CDNs represnts a list of CDNs available as of 04/01/2017 CDNs = []string{ "https://owo.whats-th.is/", "https://i.am-a.ninja/", "https://buttsare.sexy/", "https://nyanyanya.moe/", "https://all.foxgirlsare.sexy/", "https://i.stole-a-me.me/", "https://can-i-ask-dean-on-a.date/", "https://this.is-a.dog/", "https://deanis.sexy/", } )
Functions ¶
func ShortenURL ¶
ShortenURL shortens a single url using the global client
Types ¶
type Client ¶
Client stores http client and key
func (*Client) ShortenURL ¶
ShortenURL shortens a single url
func (*Client) ShortenURLs ¶
ShortenURLs shortens multiple urls
func (*Client) UploadFile ¶
UploadFile uploads a file
func (*Client) UploadFiles ¶
UploadFiles uploads multiple files using the global client
type ErrFileTooBig ¶
ErrFileTooBig thrown when file exceeds hardcoded filesize limit
func (ErrFileTooBig) Error ¶
func (e ErrFileTooBig) Error() string
type ErrTooManyFiles ¶ added in v1.2.2
type ErrTooManyFiles struct {
Count int
}
ErrTooManyFiles thrown when file count in upload exceeds filecount limit
func (ErrTooManyFiles) Error ¶ added in v1.2.2
func (e ErrTooManyFiles) Error() string
type ErrUploadFailed ¶ added in v1.3.0
ErrUploadFailed thrown when success flag on response is false
func (ErrUploadFailed) Error ¶ added in v1.3.0
func (e ErrUploadFailed) Error() string
type File ¶
type File struct { Hash string `json:"hash,omitempty"` Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` Size int `json:"size,omitempty"` Error bool `json:"error,omitempty"` Errorcode int `json:"errorcode,omitempty"` Description string `json:"description,omitempty"` }
File represents a single file from json response (if there were no errors)
type NamedReader ¶
NamedReader wrapper for a single file to upload
func FilesToNamedReaders ¶
func FilesToNamedReaders(names []string) (files []NamedReader, err error)
FilesToNamedReaders Converts a list of file names to named readers.
type Response ¶
type Response struct { Success bool `json:"success"` Errorcode int `json:"errorcode"` Description string `json:"description"` Files []File `json:"files"` }
Response contains json marshalled response from owo
func UploadFile ¶
func UploadFile(ctx context.Context, r NamedReader) (response *Response, err error)
UploadFile uploads a file using the global client
func UploadFiles ¶
func UploadFiles(ctx context.Context, rs []NamedReader) (response *Response, err error)
UploadFiles uploads multiple files using the global client