Documentation ¶
Index ¶
- Constants
- Variables
- func NewRequest(method, url string, header http.Header, body io.Reader) (*http.Request, error)
- func ParseCredentials(post *Post) (*hawk.Credentials, error)
- func SetTimeout(t time.Duration)
- func SplitType(typ string) (base string, fragment string)
- func TypeBase(typ string) string
- type AccessTokenRequest
- type AccessTokenResponse
- type App
- type AppAuth
- type AppTypes
- type Client
- func (client *Client) CreatePost(post *Post) error
- func (client *Client) GetAttachment(entity, digest string) (body io.ReadCloser, header http.Header, err error)
- func (client *Client) GetChildren(entity, post, version string, r *PageRequest) (*PostListPage, error)
- func (client *Client) GetFeed(q *PostsFeedQuery, r *PageRequest) (*PostListPage, error)
- func (client *Client) GetMentions(entity, post string, r *PageRequest) (*PostListPage, error)
- func (client *Client) GetPost(entity, id, version string, r *PostRequest) (*PostEnvelope, error)
- func (client *Client) GetPostAttachment(entity, post, version, name, accept string) (body io.ReadCloser, header http.Header, err error)
- func (client *Client) GetVersions(entity, post string, r *PageRequest) (*PostListPage, error)
- func (client *Client) NewRequest(method, url string, header http.Header, body []byte) (*http.Request, error)
- func (client *Client) Request(req func(*MetaPostServer) error) error
- func (client *Client) RequestAccessToken(code string) (*hawk.Credentials, error)
- func (client *Client) SignRequest(req *http.Request, body []byte)
- type Credentials
- type MetaPost
- type MetaPostServer
- type MetaPostServerURLs
- func (urls *MetaPostServerURLs) AttachmentURL(entity, digest string) string
- func (urls *MetaPostServerURLs) OAuthURL(appID string, state string) string
- func (urls *MetaPostServerURLs) PostAttachmentURL(entity, post, version, name string) string
- func (urls *MetaPostServerURLs) PostURL(entity, post, version string) string
- type MetaProfile
- type MultipartPostWriter
- type PageHeader
- type PageLinks
- type PageRequest
- type Post
- type PostApp
- type PostAttachment
- type PostEnvelope
- type PostLicense
- type PostListPage
- type PostMention
- type PostPermissions
- type PostRef
- type PostRequest
- type PostVersion
- type PostVersionParent
- type PostsFeedQuery
- func (q *PostsFeedQuery) Before(t time.Time, version string) *PostsFeedQuery
- func (q *PostsFeedQuery) Entities(entities ...string) *PostsFeedQuery
- func (q *PostsFeedQuery) Limit(n int) *PostsFeedQuery
- func (q *PostsFeedQuery) MaxRefs(n int) *PostsFeedQuery
- func (q *PostsFeedQuery) Mentions(mentions ...[]string) *PostsFeedQuery
- func (q *PostsFeedQuery) Since(t time.Time, version string) *PostsFeedQuery
- func (q *PostsFeedQuery) Types(types ...string) *PostsFeedQuery
- func (q *PostsFeedQuery) Until(t time.Time, version string) *PostsFeedQuery
- type ReadLenSeeker
- type RequestError
- type ResponseError
- type ResponseErrorType
- type TentError
- type UnixTime
Constants ¶
View Source
const ( PostTypeApp = "https://tent.io/types/app/v0#" PostTypeAppAuth = "https://tent.io/types/app-auth/v0#" PostTypeCredentials = "https://tent.io/types/credentials/v0#" )
View Source
const ( MediaTypePost = "application/vnd.tent.post.v0+json" MediaTypePostsFeed = "application/vnd.tent.posts-feed.v0+json" MediaTypePostVersions = "application/vnd.tent.post-versions.v0+json" MediaTypePostMentions = "application/vnd.tent.post-mentions.v0+json" MediaTypePostChildren = "application/vnd.tent.post-children.v0+json" )
View Source
const MediaTypeError = "application/vnd.tent.error.v0+json"
View Source
const RelCredentials = "https://tent.io/rels/credentials"
View Source
const RelMetaPost = "https://tent.io/rels/meta-post"
View Source
const TokenTypeHawk = "https://tent.io/oauth/hawk-token"
Variables ¶
View Source
var ErrInvalidLink = errors.New("tent: invalid meta Link")
View Source
var ErrMissingCredentialsLink = errors.New("tent: missing credentials link")
View Source
var ErrNoPage = errors.New("tent: the requested page does not exist")
View Source
var ErrNotTentEntity = errors.New("tent: not a valid Tent entity")
View Source
var HTTP = newHTTPClient(timeout)
View Source
var UnixTimeUnmarshalError = errors.New("tent: invalid unix timestamp")
View Source
var UserAgent = "tent-go/1"
Functions ¶
func NewRequest ¶
func ParseCredentials ¶
func SetTimeout ¶
Types ¶
type AccessTokenRequest ¶
type AccessTokenResponse ¶
type AccessTokenResponse struct { HawkID string `json:"access_token"` HawkKey string `json:"hawk_key"` HawkAlgorithm string `json:"hawk_algorithm"` TokenType string `json:"token_type"` }
func (*AccessTokenResponse) HawkCredentials ¶
func (res *AccessTokenResponse) HawkCredentials(app string) *hawk.Credentials
type App ¶
type App struct { Name string `json:"name"` URL string `json:"url"` Description string `json:"description,omitempty"` Scopes []string `json:"scopes,omitempty"` Types AppTypes `json:"types,omitempty"` RedirectURI string `json:"redirect_uri"` NotificationURL string `json:"notification_url,omitempty"` NotificationTypes []string `json:"notification_types,omitempty"` Post *Post `json:"-"` }
type Client ¶
type Client struct { Credentials *hawk.Credentials Servers []MetaPostServer }
func (*Client) CreatePost ¶
func (*Client) GetAttachment ¶
func (*Client) GetChildren ¶
func (client *Client) GetChildren(entity, post, version string, r *PageRequest) (*PostListPage, error)
func (*Client) GetFeed ¶
func (client *Client) GetFeed(q *PostsFeedQuery, r *PageRequest) (*PostListPage, error)
func (*Client) GetMentions ¶
func (client *Client) GetMentions(entity, post string, r *PageRequest) (*PostListPage, error)
func (*Client) GetPost ¶
func (client *Client) GetPost(entity, id, version string, r *PostRequest) (*PostEnvelope, error)
func (*Client) GetPostAttachment ¶
func (*Client) GetVersions ¶
func (client *Client) GetVersions(entity, post string, r *PageRequest) (*PostListPage, error)
func (*Client) NewRequest ¶
func (*Client) RequestAccessToken ¶
type Credentials ¶
type MetaPost ¶
type MetaPost struct { Entity string `json:"entity"` Profile MetaProfile `json:"profile"` Servers []MetaPostServer `json:"servers"` Post *Post `json:"-"` }
func GetMetaPost ¶
type MetaPostServer ¶
type MetaPostServer struct { Version string `json:"version"` Preference int `json:"preference"` URLs MetaPostServerURLs `json:"urls"` }
type MetaPostServerURLs ¶
type MetaPostServerURLs struct { OAuthAuth string `json:"oauth_auth"` OAuthToken string `json:"oauth_token"` PostsFeed string `json:"posts_feed"` Post string `json:"post"` NewPost string `json:"new_post"` PostAttachment string `json:"post_attachment"` Attachment string `json:"attachment"` Batch string `json:"batch"` ServerInfo string `json:"server_info"` }
func (*MetaPostServerURLs) AttachmentURL ¶
func (urls *MetaPostServerURLs) AttachmentURL(entity, digest string) string
func (*MetaPostServerURLs) OAuthURL ¶
func (urls *MetaPostServerURLs) OAuthURL(appID string, state string) string
func (*MetaPostServerURLs) PostAttachmentURL ¶
func (urls *MetaPostServerURLs) PostAttachmentURL(entity, post, version, name string) string
func (*MetaPostServerURLs) PostURL ¶
func (urls *MetaPostServerURLs) PostURL(entity, post, version string) string
type MetaProfile ¶
type MultipartPostWriter ¶
type MultipartPostWriter struct {
// contains filtered or unexported fields
}
func NewMultipartPostWriter ¶
func NewMultipartPostWriter(w io.Writer) *MultipartPostWriter
func (*MultipartPostWriter) Close ¶
func (w *MultipartPostWriter) Close() error
func (*MultipartPostWriter) ContentType ¶
func (w *MultipartPostWriter) ContentType() string
func (*MultipartPostWriter) WriteAttachment ¶
func (w *MultipartPostWriter) WriteAttachment(att *PostAttachment) error
func (*MultipartPostWriter) WritePost ¶
func (w *MultipartPostWriter) WritePost(post *Post) error
type PageHeader ¶
type PageRequest ¶
type Post ¶
type Post struct { ID string `json:"id,omitempty" sfilter:"version"` Entity string `json:"entity,omitempty" sfilter:"version"` OriginalEntity string `json:"original_entity,omitempty"` Type string `json:"type" sfilter:"version"` Content json.RawMessage `json:"content,omitempty" sfilter:"version"` Version *PostVersion `json:"version,omitempty" sfilter:"version"` Refs []PostRef `json:"refs,omitempty" sfilter:"version"` Mentions []PostMention `json:"mentions,omitempty" sfilter:"version"` Licenses []PostLicense `json:"licenses,omitempty" sfilter:"version"` Attachments []*PostAttachment `json:"attachments,omitempty" sfilter:"version"` Permissions *PostPermissions `json:"permissions,omitempty"` App *PostApp `json:"app,omitempty" sfilter:"version"` ReceivedAt *UnixTime `json:"received_at,omitempty"` PublishedAt *UnixTime `json:"published_at,omitempty" sfilter:"version"` Links []link.Link `json:"-"` Notification bool `json:"-"` }
func NewAppPost ¶
func (*Post) LinkedCredentials ¶
type PostAttachment ¶
type PostAttachment struct { Name string `json:"name" sfilter:"version"` Category string `json:"category" sfilter:"version"` ContentType string `json:"content_type" sfilter:"version"` Size int64 `json:"size,omitempty" sfilter:"version"` Digest string `json:"digest,omitempty" sfilter:"version"` // Include Data to upload a new attachment with the post Data ReadLenSeeker `json:"-"` // contains filtered or unexported fields }
func (*PostAttachment) Close ¶
func (att *PostAttachment) Close() error
type PostEnvelope ¶
func GetPost ¶
func GetPost(url string) (*PostEnvelope, error)
type PostLicense ¶
type PostLicense struct {
URL string `json:"url" sfilter:"version"`
}
type PostListPage ¶
type PostListPage struct { Mentions []*PostMention `json:"mentions,omitempty"` Versions []*PostVersion `json:"versions,omitempty"` Posts []*Post `json:"posts,omitempty"` Links PageLinks `json:"pages"` Header PageHeader `json:"-"` }
func (*PostListPage) First ¶
func (f *PostListPage) First() (*PostListPage, error)
func (*PostListPage) Last ¶
func (f *PostListPage) Last() (*PostListPage, error)
func (*PostListPage) Next ¶
func (f *PostListPage) Next() (*PostListPage, error)
func (*PostListPage) Prev ¶
func (f *PostListPage) Prev() (*PostListPage, error)
type PostMention ¶
type PostMention struct { Entity string `json:"entity,omitempty" sfilter:"version"` OriginalEntity string `json:"original_entity,omitempty"` Post string `json:"post,omitempty" sfilter:"version"` Version string `json:"version,omitempty" sfilter:"version"` Type string `json:"type,omitempty" sfilter:"version"` PublicFlag *bool `json:"public,omitempty"` // nil or true is public == true; false is public == false }
func (*PostMention) Public ¶
func (mention *PostMention) Public() bool
type PostPermissions ¶
type PostPermissions struct { PublicFlag *bool `json:"public,omitempty"` // nil or true is public == true; false is public == false Groups []string `json:"groups,omitempty"` Entities []string `json:"entities,omitempty"` }
func (*PostPermissions) Public ¶
func (perm *PostPermissions) Public() bool
type PostRef ¶
type PostRef struct { Entity string `json:"entity,omitempty" sfilter:"version"` OriginalEntity string `json:"original_entity,omitempty"` Post string `json:"post,omitempty" sfilter:"version"` Version string `json:"version,omitempty" sfilter:"version"` Type string `json:"type,omitempty" sfilter:"version"` }
type PostRequest ¶
type PostRequest struct {
MaxRefs int
}
type PostVersion ¶
type PostVersion struct { ID string `json:"id,omitempty"` Parents []PostVersionParent `json:"parents,omitempty" sfilter:"version"` Message string `json:"message,omitempty" sfilter:"version"` PublishedAt *UnixTime `json:"published_at,omitempty" sfilter:"version"` ReceivedAt *UnixTime `json:"received_at,omitempty"` // Used in post version and children lists Type string `json:"type,omitempty"` Entity string `json:"entity,omitempty"` Post string `json:"post,omitempty"` }
type PostVersionParent ¶
type PostsFeedQuery ¶
func NewPostsFeedQuery ¶
func NewPostsFeedQuery() *PostsFeedQuery
func (*PostsFeedQuery) Before ¶
func (q *PostsFeedQuery) Before(t time.Time, version string) *PostsFeedQuery
func (*PostsFeedQuery) Entities ¶
func (q *PostsFeedQuery) Entities(entities ...string) *PostsFeedQuery
func (*PostsFeedQuery) Limit ¶
func (q *PostsFeedQuery) Limit(n int) *PostsFeedQuery
func (*PostsFeedQuery) MaxRefs ¶
func (q *PostsFeedQuery) MaxRefs(n int) *PostsFeedQuery
func (*PostsFeedQuery) Mentions ¶
func (q *PostsFeedQuery) Mentions(mentions ...[]string) *PostsFeedQuery
func (*PostsFeedQuery) Since ¶
func (q *PostsFeedQuery) Since(t time.Time, version string) *PostsFeedQuery
func (*PostsFeedQuery) Types ¶
func (q *PostsFeedQuery) Types(types ...string) *PostsFeedQuery
func (*PostsFeedQuery) Until ¶
func (q *PostsFeedQuery) Until(t time.Time, version string) *PostsFeedQuery
type ReadLenSeeker ¶
type ReadLenSeeker interface { io.ReadSeeker Len() int64 }
type RequestError ¶
func (*RequestError) Error ¶
func (e *RequestError) Error() string
type ResponseError ¶
type ResponseError struct { Type ResponseErrorType Response *http.Response TentError *TentError }
func (*ResponseError) Error ¶
func (e *ResponseError) Error() string
type ResponseErrorType ¶
type ResponseErrorType int
const ( ErrBadStatusCode ResponseErrorType = iota ErrBadContentType ErrBadData ErrReadTimeout )
Click to show internal directories.
Click to hide internal directories.