An enum that represent all valid HTTP methods.
Config objects allow Requests that uses different URL representations than Strings and different error types than Http.Error.
The default config
Create a simple http request
Represents the expected response in an Http request
Declares a request that expects a JSON response handled with the given decoder.
Declares a request that expects a binary response handled with the given decoder.
Declares a request that expects a simple string response.
Ignores the content of the received response.
Convert a request to a command.
This function requires a config object. If you don not need one, use the simple
config exported by this package.
Request.get
{ url = "https://example.com"
, expect = Request.expectJson Json.Decode.string
}
|> Request.cmd Request.simple ResponseReceivedConvert a request to a task.
This function requires a config object. If you don not need one, use the simple
config exported by this package.
Request.get
{ url = "https://example.com"
, expect = Request.expectJson Json.Decode.string
}
|> Request.task Request.simpleDeclares a JSON body
Declares a string body by specifing the content type and the data.
Request.get
{ url = "https://example.com"
, expect = Request.expectJson Json.Decode.string
}
|> Request.withStringBody "text/plain" "Some text"Set the request body to be empty.
Declares a Binary body with a given content type.
Declares a File body with a given file and an optional identifier.
The name can be used to track the download progress of the file by subscribing
to events created by Http.tracker id onProgressMsg.
Set the request body using some instance of Http.Body
Http.stringBody "text/plain" "Some text"Requests expose some helper functions, but for more complex cases, you should refer to the Http module.
Adds a list of headers to the request.
Request.get
{ url = "https://example.com"
, expect = Request.expectJson Json.Decode.string
}
|> Request.withHeaders [ ( "Authorization", "Bearer " ++ token ) ]Adds a query parameter to the final url
Request.get
{ url = "https://example.com"
, expect = Request.expectJson Json.Decode.string
}
|> Request.withQuery "search" "what is the answer to the question of life, the universe and everything?"Adds an integer query parameter to the final url
Request.get
{ url = "https://example.com"
, expect = Request.expectJson Json.Decode.string
}
|> Request.withIntQuery "default-answer" 42Ignore specific default headers declared in the config.
Request.get
{ url = "https://example.com"
, expect = Request.expectJson Json.Decode.string
}
|> Request.excludeDefaultHeaders [ "Authorization", "Cookie" ]Ignore all default headers declared in the config.
Request.get
{ url = "https://example.com"
, expect = Request.expectJson Json.Decode.string
}
|> Request.ignoreDefaultHeaders
Represent an HTTP request