patron-0.2.1 doesn't have any documentation.
patron
A wrapper around the hyper.rs library to allow for targeted clients to specific remote APIs. This library should be useful on it's own or as a building block for specific remote API wrappers.
The Interface
Exports
We want to give out an owned std::sync::Arc
wrapped client so that the user can
utilize the client between threads if ncessary.
pub type Client = Arc;
Create an HTTP Star Wars API client.
let client = try!;
let han_solo: Person = try!client.get
.send
.and_then
);
Creating an HTTPs GitHub Api client with an OAuth2 token.
use patron;
let client: Client = try!;
Creating an HTTPs GitHub Api client using query based tokens.
use patron;
let client: Client = try!;
Creating an HTTP client for CouchDB.
use patron;
let url: Url = try!;
let client: Client = try!;
Example usage for ArangoDB
THIS IS NOT FULLY IMPLEMENTED, LIES ABOUND!
use serde_json;
use patron;
// Generally this would be built from some configuration object.
let mut url = new
url.set_scheme
url.set_host
url.set_port
let auth: AuthRes = try!;
let mydb_client: Client = try!;
let version: Version = try!;
let newdoc: NewDoc = try!;
let mut hello: Document = try!;
hello.message = Some;
let res: UpdateRes = try!;
Design
Response Objects: Fetch API
Notes
- Should the client be passed into the send method?
- I would like to only have one representation of a request configuration instead of the current 2.
- A more functional style design?
- I like how the fetch API returns a response object with the ability to retrieve the
Body
in different formats. How can this be presented along with a niceResult
based interface?client.get .send .unwrap .json
send()
will return aResponse
object which you can call.json()
. The.json()
method will return aResult<serde_json::Value, Error>