Adds support for tracker
on requests
HttpBuilder.withTracker
: adds a tracker key to the request builder
- Add a new property
tracker
toRequestBuilder
Fixes misspelled content-type for x-www-form-urlencoded bodies
- Fixes misspelled content-type for x-www-form-urlencoded bodies. Prior to this change
it was spelled
x-www-form-urlencode
, which is missing the finald
. Fix provided by @TheAlemazing.
Upgrades the underlying elm/http version to the 2.0.0 API.
HttpBuilder.Task
: a new module that allows you to build a call toHttp.task
orHttp.riskyTask
. We need this because sending a request as aTask
is sufficiently different from usingHttp.request
that we can't construct them using the same type and still have a nice API.
HttpBuilder.withExpectJson
,HttpBuilder.withExpectString
: just usewithExpect
HttpBuilder.toRequest
: theRequest
type doesn't exist anymoreHttpBuilder.queryParam
,HttpBuilder.queryParams
: use theUrl.Builder
module from elm/url to build up URLsHttpBuilder.requestUrl
: theurl
field onRequestBuilder
is the full URL now
HttpBuilder.send
->HttpBuilder.request
: to match the name of the related function inHttp
- Upgrades elm/http version to 2.0.0
- Thanks to @dvekeman for doing a bunch of work toward this release
withBearerToken
: add anAuthorization: Bearer
header (@amarantedaniel)withExpectJson
: shortcut for usingHttp.expectJson
(@dbottisti)withExpectString
: shortcut for usingHttp.expectString
(@dbottisti)
- Upgrade
elm-test
- Remove my old Twitter handle from README
This release accomplishes two goals.
-
The
RequestBuilder
type is no longer opaque. This comes after observing much debate in the community over the merits and drawbacks of hiding details of a library's types from the user. In this case I have determined it no longer makes sense to do so. IfRequestBuilder
is opaque and so isHttp.Request
, there is no longer any opportunity to do introspection, write tests, or create tooling around theRequestBuilder
type. So we simply expose the internal structure ofRequestBuilder
as a record. -
We're taking over the
send
function again. Thanks to a pull request by @s60 I am convinced that this will be okay. We can still have the same signature forsend
, and then use tasks inside ofsend
to mess around and do extra stuff. This will just require that the docs fortoRequest
be very clear that it is lossy with respect toHttpBuilder
features. So far there is one new feature that is being brought over from the previous versions,withCacheBuster
. This will be a foundation for bringing back other stuff and adding new things as well.
None
RequestBuilder a
is no longer opaque
toTask
: Convert yourRequestBuilder a
into aTask Http.Error a
with all the extras thatHttpBuilder
has and will have to offer.withCacheBuster
: append a cache buster query param with the current timestamp to your request's URL.
A lot has happened since 3.0.0! The API is smaller, and more focused and I'm
excited about that. In particular, BodyReader
and its friends have been
removed. Since this is the official upgrade for Elm 0.18, the new
elm-lang/http
package has a lot of influence. The new Http
package includes
a much more cohesive experience for declaring expectations of response bodies.
See the Http.Expect
type in elm-lang/http
.
This feature is even reminiscent of BodyReader
!
Since we have this as a part of the platform now, all of the BodyReader
-
related features are gone. For these you'll just "use the platform", as they
say, and make use of withExpect
in your builder pipelines. In the future
we may include fancier, custom Expect
formulations for your convenience.
Secondly, you'll now have the option to convert a RequestBuilder a
into an
Http.Request a
or send it directly using HttpBuilder.send
, which has the
same signature as Http.send
. This helps to keep your builder pipelines clean
while also leaving you the option to get out an Http.Request
if you need.
Long story short, HttpBuilder
is just about building requests, just like
when it started out. The platform covers the rest.
Here's the list of all changes:
url
: usewithQueryParams
instead to add query params to your urlwithBody
: use one of the more specificwith*Body
functions insteadwithMultipartBody
: string multipart bodies are the only type supported byelm-lang/http
currently, sojust usewithMultipartStringBody
insteadwithMimeType
: the first parameter towithStringBody
will set your MIME type automatically. Alternatively, set a header withwithHeader
withCacheBuster
: since we're giving up control of the send process, we can't chain on aTask
to get the current timewithZeroStatusAllowed
: we don't control the send process. You can handle this yourself under theHttp.BadStatus
error when you deal with errors in your send msg tagger.BodyReader
: see introstringReader
: see introjsonReader
: see introunitReader
: see introError
: since we don't control the send process we don't need thisResponse
: same asError
toSettings
:Http.Settings
doesn't exist anymore, it was moved underHttp.Request
Request
: since we expect you'll need to importHttp
now anyway, you can just import this fromHttp
Settings
: seetoSettings
RequestBuilder
->RequestBuilder a
, where the type parameter is the expected type of the returned payload.get
,post
, etc. returnRequestBuilder ()
. The default is to make no attempt to decode anything, so it is()
. You can usewithExpect
to attach anHttp.Expect MyType
, which will turn it into aRequestBuilder MyType
.toRequest
returns anHttp.Request a
send
wrapsHttp.send
, read up on it to see how it works.
withExpect
: attach anHttp.Expect
to the requestwithQueryParams
: decorate the URL with query params
A sincere thank you to @evancz, @rtfeldman, @bogdanp, and @knewter for time and discussions that helped me make the decisions that led to these changes!
And a shoutout to @prikhi for taking the time to update the existing API for 0.18 and publishing it as priki/elm-http-builder.