File tree Expand file tree Collapse file tree 3 files changed +45
-10
lines changed Expand file tree Collapse file tree 3 files changed +45
-10
lines changed Original file line number Diff line number Diff line change 55//! The `Client` API is designed for most people to make HTTP requests.
66//! It utilizes the lower level `Request` API.
77//!
8- //! ```no_run
9- //! use hyper::Client;
8+ //! ## GET
109//!
10+ //! ```no_run
11+ //! # use hyper::Client;
1112//! let mut client = Client::new();
1213//!
13- //! let mut res = client.get("http://example.domain").send().unwrap();
14+ //! let res = client.get("http://example.domain").send().unwrap();
1415//! assert_eq!(res.status, hyper::Ok);
1516//! ```
1617//!
17- //! The returned value from is a `Response`, which provides easy access
18- //! to the `status`, the `headers`, and the response body via the `Writer `
18+ //! The returned value is a `Response`, which provides easy access to
19+ //! the `status`, the `headers`, and the response body via the `Read `
1920//! trait.
21+ //!
22+ //! ## POST
23+ //!
24+ //! ```no_run
25+ //! # use hyper::Client;
26+ //! let mut client = Client::new();
27+ //!
28+ //! let res = client.post("http://exmaple.domain")
29+ //! .body("foo=bar")
30+ //! .send()
31+ //! .unwrap();
32+ //! assert_eq!(res.status, hyper::Ok);
33+ //! ```
2034use std:: default:: Default ;
2135use std:: io:: { self , copy, Read } ;
2236use std:: iter:: Extend ;
Original file line number Diff line number Diff line change 99//! is a low-level typesafe abstraction over raw HTTP, providing an elegant
1010//! layer over "stringly-typed" HTTP.
1111//!
12- //! Hyper offers both an HTTP/S client an HTTP server which can be used to drive
13- //! complex web applications written entirely in Rust.
12+ //! Hyper offers both a [Client](client/index.html) and a
13+ //! [Server](server/index.html) which can be used to drive complex web
14+ //! applications written entirely in Rust.
1415//!
1516//! ## Internal Design
1617//!
2021//!
2122//! ### Common Functionality
2223//!
23- //! Functionality and code shared between the Server and Client implementations can
24- //! be found in `src` directly - this includes `NetworkStream`s, `Method`s,
24+ //! Functionality and code shared between the Server and Client implementations
25+ //! can be found in `src` directly - this includes `NetworkStream`s, `Method`s,
2526//! `StatusCode`, and so on.
2627//!
2728//! #### Methods
3839//!
3940//! #### Headers
4041//!
41- //! Hyper's header representation is likely the most complex API exposed by Hyper.
42+ //! Hyper's [header](header/index.html) representation is likely the most
43+ //! complex API exposed by Hyper.
4244//!
4345//! Hyper's headers are an abstraction over an internal `HashMap` and provides a
4446//! typesafe API for interacting with headers that does not rely on the use of
Original file line number Diff line number Diff line change 11//! HTTP Server
2+ //!
3+ //! # Example
4+ //!
5+ //! ```no_run
6+ //! use hyper::server::{Server, Request, Response};
7+ //! use hyper::status::StatusCode;
8+ //! use hyper::uri::RequestUri;
9+ //!
10+ //! let server = Server::http(|req: Request, mut res: Response| {
11+ //! *res.status_mut() = match (req.method, req.uri) {
12+ //! (hyper::Get, RequestUri::AbsolutePath(ref path)) if path == "/" => {
13+ //! StatusCode::Ok
14+ //! },
15+ //! (hyper::Get, _) => StatusCode::NotFound,
16+ //! _ => StatusCode::MethodNotAllowed
17+ //! };
18+ //!
19+ //! res.start().unwrap().end().unwrap();
20+ //! }).listen("0.0.0.0:8080").unwrap();
221use std:: fmt;
322use std:: io:: { ErrorKind , BufWriter , Write } ;
423use std:: marker:: PhantomData ;
You can’t perform that action at this time.
0 commit comments