Skip to content

Commit e814680

Browse files
committed
Merge pull request #473 from hyperium/docup
Docup
2 parents e234cbe + 48a010f commit e814680

File tree

3 files changed

+45
-10
lines changed

3 files changed

+45
-10
lines changed

src/client/mod.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,32 @@
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+
//! ```
2034
use std::default::Default;
2135
use std::io::{self, copy, Read};
2236
use std::iter::Extend;

src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
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
//!
@@ -20,8 +21,8 @@
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
@@ -38,7 +39,8 @@
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

src/server/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
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();
221
use std::fmt;
322
use std::io::{ErrorKind, BufWriter, Write};
423
use std::marker::PhantomData;

0 commit comments

Comments
 (0)