Documentation
¶
Index ¶
Constants ¶
View Source
const EventMime = mimetype.ApplicationMsgPack
Variables ¶
View Source
var ( ErrUnsuccessfulReply = Reply{Success: false} ErrNotFoundReply = Reply{Success: false, Error: "resource not found"} ErrNotAllowedReply = Reply{Success: false, Error: "method not allowed"} ErrUnparsable = Reply{Success: false, Error: "could not parse json request"} )
View Source
var ( ErrMissingURL = errors.New("a url is required for shortening") ErrCannotParseExpires = errors.New("expires must be a timestamp in the form of YYYY-MM-DD or YYYY-MM-DD HH:MM:SS") ErrInvalidExpires = errors.New("expiration must be valid timestamp in the future") ErrParseBearer = errors.New("could not parse Bearer token from Authorization header") ErrNoAuthorization = errors.New("no authorization header in request") ErrInvalidToken = errors.New("invalid bearer token in Authorization header") ErrUnauthenticated = errors.New("this endpoint requires authentication") ErrForwardsBackwards = errors.New("cannot specify both prev and next page token in page query") )
View Source
var ClickType = &api.Type{ Name: "Click", MajorVersion: pkg.VersionMajor, MinorVersion: pkg.VersionMinor, PatchVersion: pkg.VersionPatch, }
View Source
var DeletedType = &api.Type{ Name: "Deleted", MajorVersion: pkg.VersionMajor, MinorVersion: pkg.VersionMinor, PatchVersion: pkg.VersionPatch, }
View Source
var ShortenedType = &api.Type{ Name: "Shortened", MajorVersion: pkg.VersionMajor, MinorVersion: pkg.VersionMinor, PatchVersion: pkg.VersionPatch, }
Functions ¶
Types ¶
type Click ¶ added in v1.1.0
type Click struct { URL string `json:"url" msgpack:"url"` Time string `json:"time" msgpack:"time"` Views int `json:"views" msgpack:"views"` UserAgent string `json:"user_agent" msgpack:"user_agent"` IPAddr string `json:"ip_address" msgpack:"ip_address"` }
func (*Click) MarshalValue ¶ added in v1.1.0
func (*Click) UnmarshalValue ¶ added in v1.1.0
type Deleted ¶ added in v1.1.0
func (*Deleted) MarshalValue ¶ added in v1.1.0
func (*Deleted) UnmarshalValue ¶ added in v1.1.0
type InfoDetail ¶ added in v1.1.0
type LoginData ¶ added in v1.2.0
func GetLoginData ¶ added in v1.2.0
func GetLoginData() LoginData
type LoginForm ¶ added in v1.1.0
type LoginForm struct { Credential string `json:"credential" url:"credential" form:"credential"` Next string `json:"next" url:"next" form:"next"` }
LoginForm is used for Google to submit an id token back to the server.
type LongURL ¶ added in v0.2.0
type PageQuery ¶
type PageQuery struct { PageSize int `json:"page_size" url:"page_size,omitempty" form:"page_size"` PrevPageToken string `json:"prev_page_token" url:"prev_page_token,omitempty" form:"prev_page_token"` NextPageToken string `json:"next_page_token" url:"next_page_token,omitempty" form:"next_page_token"` }
PageQuery manages paginated list requests.
type Reply ¶
Reply contains standard fields that are used for generic API responses and errors.
func ErrorResponse ¶
func ErrorResponse(err interface{}) Reply
Construct a new response for an error or simply return unsuccessful.
type Service ¶ added in v1.0.0
type Service interface { // Unauthenticated endpoints Status(context.Context) (*StatusReply, error) // URL Management // TODO: edit short url with details ShortURLList(context.Context, *PageQuery) (*ShortURLList, error) ShortenURL(context.Context, *LongURL) (*ShortURL, error) ShortURLInfo(context.Context, string) (*ShortURL, error) DeleteShortURL(context.Context, string) error // Websockets Updates(context.Context, string) (<-chan *Click, error) }
type ShortURL ¶ added in v0.2.0
type ShortURL struct { URL string `json:"url"` AltURL string `json:"alt_url,omitempty"` Target string `json:"target,omitempty"` Title string `json:"title"` Description string `json:"description,omitempty"` Visits uint64 `json:"visits"` Expires *time.Time `json:"expires,omitempty"` Created *time.Time `json:"created,omitempty"` Modified *time.Time `json:"modified,omitempty"` CampaignID uint64 `json:"campaign_id,omitempty"` Campaigns []uint64 `json:"campaigns,omitempty"` }
TODO: change campaign uint64s to links
func (*ShortURL) WebData ¶ added in v1.1.0
func (s *ShortURL) WebData() InfoDetail
type ShortURLList ¶ added in v1.1.0
func (*ShortURLList) WebData ¶ added in v1.1.0
func (s *ShortURLList) WebData() LinkList
type ShortcrustInfo ¶ added in v1.2.0
type ShortcrustInfo struct { Links uint64 `json:"links"` Clicks uint64 `json:"clicks"` Campaigns uint64 `json:"campaigns"` }
func (*ShortcrustInfo) CampaignsPerLink ¶ added in v1.2.0
func (s *ShortcrustInfo) CampaignsPerLink() float64
func (*ShortcrustInfo) WebData ¶ added in v1.2.0
func (s *ShortcrustInfo) WebData() Stats
type Shortened ¶ added in v1.1.0
type Shortened struct { URL string `msgpack:"url"` AltURL string `msgpack:"alt_url"` Title string `msgpack:"title"` Description string `msgpack:"description"` Expires *time.Time `msgpack:"expires,omitempty"` CampaignID uint64 `msgpack:"campaign_id,omitempty"` Campaigns []uint64 `msgpack:"campaigns,omitempty"` }
func (*Shortened) MarshalValue ¶ added in v1.1.0
func (*Shortened) UnmarshalValue ¶ added in v1.1.0
type Stats ¶ added in v1.2.0
type Stats struct { WebData Info *ShortcrustInfo }
type StatusReply ¶
type StatusReply struct { Status string `json:"status"` Uptime string `json:"uptime,omitempty"` Version string `json:"version,omitempty"` }
Returned on status requests.
Click to show internal directories.
Click to hide internal directories.