Skip to content

v1.13.0

Latest

Choose a tag to compare

@tirthpatell tirthpatell released this 22 Nov 04:13
a11e646

What's changed

Four additions, all contributed by @yama6a (#43). This release compiles against existing code.

New

Custom http.Client (#45)

Set Config.HTTPClient to send every request, including the token endpoints, through your own client, for example a per-account proxy. The library uses it as given and never modifies it. HTTPTimeout does not apply to it, so set the client's own Timeout.

Requests follow the caller's context (#46)

Client methods used to accept a ctx but send requests with context.Background(). They now pass it through, so cancelling the context or reaching its deadline stops the request. HTTPClient gains GETContext, POSTContext, PUTContext and DELETEContext; the existing GET, POST, PUT and DELETE are unchanged.

ContainerError (#47)

When a media container ends in ERROR or EXPIRED, publishing now returns a *ContainerError with the container ID, status and message. Check it with IsContainerError or errors.As. The error text is the same as before.

PostsOptions.Fields (#48)

Choose which fields GetUserPostsWithOptions, GetUserMentions, GetPublicProfilePosts and GetUserReplies request. An empty list keeps the defaults.

Behavior changes

  • A cancelled or expired context returns a non-temporary NetworkError and stops retries at once. errors.Is finds context.Canceled or context.DeadlineExceeded in it.
  • A failed read of the response body is now a NetworkError instead of a plain error. It is still never retried.
  • DeletePost cancelled during its ownership check returns the context error instead of an authentication error.
  • PostsOptions now has a slice field, so two values can no longer be compared with ==.

Full Changelog: v1.12.0...v1.13.0