Code Monkey home page Code Monkey logo

hyperium.github.io's People

Contributors

alex avatar alexwlchan avatar alsuren avatar andir avatar bltavares avatar coder543 avatar dmacewen avatar dswij avatar edoriandark avatar exhuzaifa avatar faraazahmad avatar frewsxcv avatar fvilers avatar github-actions[bot] avatar hjr3 avatar isaaccloos avatar iwburns avatar jolhoeft avatar justinbarclay avatar kjmrknsn avatar lpghatguy avatar markhildreth avatar newbmiao avatar oddgrd avatar pyk avatar seanmonstar avatar seunghunee avatar staktrace avatar sullyj3 avatar thomspoon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hyperium.github.io's Issues

The example doesn't work with latest version 0.14.12

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.

dark mode

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

reconsider choice of service_fn for promotional code snippet

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.

Cannot Compile HTTP Client Example in the Documentation

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.

The Example From Getting Started with a Server Give Me An Error: unresolved import `hyper_util::rt::TokioIo`

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" }

Document has an error here

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)?;

Links to other guide pages are incorrect.

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.

TLS server support?

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?

Favicon/icon for hyper suggestion

I saw the issue requesting a favicon on hyper, and the subsequent PR here where it was decided to leave the favicon blank until an icon was chosen. I made this from the rust logo. What do you think? image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.