Documentation ¶
Overview ¶
Package api contains types and methods for interacting with a shorturl server.
Index ¶
- Constants
- func Expires(toAdd time.Duration) *time.Time
- type Client
- func (s *Client) CreateLink(url string) (link *db.URL, err error)
- func (s *Client) CreateLinkComplex(data CreateLinkData) (link *db.URL, err error)
- func (s *Client) EndpointInfo(link string) string
- func (s *Client) EndpointLink(link string) string
- func (s *Client) EndpointLinks(username string) string
- func (s *Client) Link(id uuid.UUID) (link *db.URL, err error)
- func (s *Client) LinkInfo(short string) (link *db.URL, err error)
- func (s *Client) Links() (links []db.URL, err error)
- func (s *Client) MyLinks() (links []db.URL, err error)
- func (s *Client) Request(method, url string, data, out interface{}) (err error)
- func (s *Client) UserLinks(username string) (links []db.URL, err error)
- type CreateLinkData
Constants ¶
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct { Client *http.Client // The user agent used by requests. UserAgent string // The default timeout for requests. Timeout time.Duration // Debug is called for debug logs. Default no-op. Debug func(tmpl string, v ...interface{}) // contains filtered or unexported fields }
Client is a shorturl API client.
func (*Client) CreateLink ¶
CreateLink creates a short URL to the given link.
func (*Client) CreateLinkComplex ¶
func (s *Client) CreateLinkComplex(data CreateLinkData) (link *db.URL, err error)
CreateLinkComplex creates a short URL to the given link.
func (*Client) EndpointInfo ¶
EndpointInfo returns the /{short}/info.json endpoint.
func (*Client) EndpointLink ¶
EndpointLink returns the /link endpoint with optional link ID. Used in Link(), CreateLink(), CreateLinkComplex(), DeleteLink().
func (*Client) EndpointLinks ¶
EndpointLinks returns the /links endpoint with optional username. Used in Links(), UserLinks(), MyLinks().
type CreateLinkData ¶
type CreateLinkData struct { // The short name for this link. Randomly generated if empty. Name string `json:"name,omitempty"` // The URL this link points to. URL string `json:"url"` // The expiry for this link. Nil if it doesn't expire. Expires *time.Time `json:"expires,omitempty"` }
CreateLinkData is the data passed to CreateLinkComplex.
Click to show internal directories.
Click to hide internal directories.