Documentation
¶
Index ¶
Constants ¶
This section is empty.
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") )
Functions ¶
Types ¶
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
}
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 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.