hyperium / hyperium.github.io Goto Github PK
View Code? Open in Web Editor NEWHome Page: http://hyper.rs
Home Page: http://hyper.rs
Right now it is broken, being rendered without an href
, the pertaining line is not rendering the variable correctly.
https://github.com/hyperium/hyperium.github.io/blob/master/_includes/header.html#L6
There's a lot of missing references on the guide page. It'd be a nice little improvement to have the highlighted text parts be resolvable links.
This can be considered an easy fix but it improves the value of the documentation significantly.
One example of this would be the referenced example
in https://hyper.rs/guides/client/json/ links to https://docs.rs/hyper/*/guides/client/basic/
Right now, hyper.rs only provides an HTTP/1 server example. It might be a good idea to add an HTTP/2 version.
This issue was raised in the hyper repository as hyperium/hyper#3568
Please assign this issue to me.
For example in https://hyper.rs/guides/1/server/hello-world/, the Service link points to https://docs.rs/hyper/hyper/service/trait.Service.html, which results in a 400 bad request response. It seems what's missing is /latest
here:
hyperium.github.io/_config.yml
Line 56 in a87c5dc
The given code on your home page:
use std::{convert::Infallible, net::SocketAddr};
use hyper::{Body, Request, Response, Server};
use hyper::service::{make_service_fn, service_fn};
async fn handle(_: Request<Body>) -> Result<Response<Body>, Infallible> {
Ok(Response::new("Hello, World!".into()))
}
#[tokio::main]
async fn main() {
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
let make_svc = make_service_fn(|_conn| async {
Ok::<_, Infallible>(service_fn(handle))
});
let server = Server::bind(&addr).serve(make_svc);
if let Err(e) = server.await {
eprintln!("server error: {}", e);
}
}
The result:
Compiling http-server v0.1.0 (/Users/chiro/GitHub/rust-playground/http-server)
error[E0432]: unresolved import `hyper::Server`
--> src/main.rs:2:38
|
2 | use hyper::{Body, Request, Response, Server};
| ^^^^^^ no `Server` in the root
error: aborting due to previous error
For more information about this error, try `rustc --explain E0432`.
error: could not compile `http-server`
To learn more, run the command again with --verbose.
The getting started guide of hyber uses extern crate hyper
https://hyper.rs/guides/client/basic/
I was the opinion that extern
is no longer necessary and the new/current module system does not require.
and indeed, I confirmed this by removing the extern
and the code snippet in the example still works...
Question now is, shouldn't extern
be removed from the documentation?
the website is bright so it might effect users using the website at night
I would like to code the dark mode of this website
This is a use case I am currently trying to use hyper for, and so far, so good I have not been able to figure how to do that out.
It would be a nice addition to the examples to include this :)
I consider hyper a defacto standard for http in the rust ecosystem. As such, it's likely going to be one of the first stops for a rust newbie.
The example code on this site using service_fn
shows how simple it is to set up a service. However, for those new to rust or even moderately acclimated are going to assume the code in the example is going to be downloadable from crates.io as an officially published crate. I just fell for that trick which required some digging to know that its not and that I needed to depend on it from git source instead. I understand that's not uncommon for experimental crate usage but I feel like hyper is not. To make the experience for first timer rustaceans a pleasant one, I might consider an example that uses only dependencies that are published to crates.io.
I'm following this documentation and come up with the following code:
extern crate hyper;
use hyper::body::HttpBody as _;
use hyper::Client;
use tokio::io::{stdout, AsyncWriteExt as _};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
// This is where we will setup our HTTP client requests.
println!("Hello?");
// Still inside `async fn main`...
let client = Client::new();
// Parse an `http::Uri`...
let uri = "http://httpbin.org/ip".parse()?;
// Await the response...
let resp = client.get(uri).await?;
println!("Response: {}", resp.status());
// And now...
while let Some(chunk) = resp.body_mut().data().await {
stdout().write_all(&chunk?).await?;
}
Ok(())
}
When I try to compile and run the examples. I got the following error:
error[E0433]: failed to resolve: use of undeclared type or module `tokio`
--> src\bin\hyper_get.rs:5:3
|
5 | #[tokio::main]
| ^^^^^ use of undeclared type or module `tokio`
warning: unused import: `hyper::Client`
--> src\bin\hyper_get.rs:3:5
|
3 | use hyper::Client;
| ^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0277]: `main` has invalid return type `impl std::future::Future`
--> src\bin\hyper_get.rs:6:20
|
PS C:\Users\bayu\pyk\rust-http-clients> cargo run --bin hyper_get
Compiling rust-http-clients v0.1.0 (C:\Users\bayu\pyk\rust-http-clients)
error[E0433]: failed to resolve: use of undeclared type or module `tokio`
--> src\bin\hyper_get.rs:5:5
|
5 | use tokio::io::{stdout, AsyncWriteExt as _};
| ^^^^^ use of undeclared type or module `tokio`
error[E0433]: failed to resolve: use of undeclared type or module `tokio`
--> src\bin\hyper_get.rs:7:3
|
7 | #[tokio::main]
| ^^^^^ use of undeclared type or module `tokio`
error[E0425]: cannot find function `stdout` in this scope
--> src\bin\hyper_get.rs:25:9
|
25 | stdout().write_all(&chunk?).await?;
| ^^^^^^ not found in this scope
|
help: possible candidate is found in another module, you can import it into scope
|
3 | use std::io::stdout;
|
error[E0277]: `main` has invalid return type `impl std::future::Future`
--> src\bin\hyper_get.rs:8:20
|
8 | async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` can only return types that implement `std::process::Termination`
|
= help: consider using `()`, or a `Result`
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0277, E0425, E0433.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `rust-http-clients`.
To learn more, run the command again with --verbose.
An example how to use hyper on server in this page give me an error: page here's the error message showed to me:
unresolved import `hyper_util::rt::TokioIo`
the item is gated behind the `tokio` feature
This is my cargo.toml:
[package]
name = "repro"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
hyper = { version = "1", features = ["full"] }
tokio = { version = "1", features = ["full"] }
http-body-util = "0.1"
hyper-util = { git = "https://github.com/hyperium/hyper-util.git" }
On Advanced Client Usage:
let (posted, got) = tokio::executor::current_thread::block_on_all(work).unwrap();
This code will cause panic SpawnError { is_shutdown: true }
relationship: tokio #337
If you want to get results in the current thread, you should do it like this:
use tokio::runtime::current_thread::Runtime;
let run_time = Runtime::new()?;
let responses = self.run_time.block_on(work)?;
We are using constructs like [Echo, echo, echo](./echo)
to link to other pages in the guides. That link appears in handle_params.md for example. When viewing the page in github, the relative linking is correct (except there is no trailing .md
). However, on the guide pages, instead of linking to https://hyper.rs/guides/server/echo/, it is linking to https://hyper.rs/guides/server/handle_post/echo
I don't know what software is generating the guide pages from the markdown, so can't figure out how to fix this.
The guide doesn't mention TLS server support, which I would argue is an important feature for many users. I realise that third-party crates are required to support TLS with hyper
, but how about linking to some of them or providing an example to make it a bit easier for new users to find? For comparison, TLS configuration is mentioned for the hyper
client and there is a link to hyper-tls
Similar to how reqwest
is mentioned in the hyper
README.md
as a high-level easy-to-use wrapper over the hyper
client, is it intended for higher-level server frameworks like warp
to be easy-to-use wrappers over the hyper
server that provide TLS? In which case how about linking to some or even to the Web Development Frameworks page on arewewebyet.org
Would you accept a PR for this?
The Echo, echo, echo article mentions the Hello, World! article as a hyperlink (dat pun!), but that link appears to be a self-reference, instead of leading there.
It looks like too many lines are commented out in the "full example" here: https://github.com/hyperium/hyperium.github.io/blob/master/_guides/client/basic.md
(e.g the run function declaration, etc)
Resulting in code that wont compile here: https://hyper.rs/guides/client/basic/
On the advanced client guide, there's an example for setting custom headers - Since the headers crate provides a safer way to talk about well-known headers, could there be an example of how to do that there?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.