Hyper: A sample for HTTPS server?

Created on 2 Dec 2016  Â·  6Comments  Â·  Source: hyperium/hyper

I'm doing some tests with hyper. I wonder if there's a bare minimum sample HTTPS server similar to the one provided with HttpListener?

Thanks.

All 6 comments

There currently is in the docs of the Openssl type: http://hyper.rs/hyper/v0.9.12/hyper/net/struct.Openssl.html

Thanks for the response. I'm still a bit troubled here. I downloaded the code and added hyper as a local extern in my code (I needed this for testing). When I want to specify a handler for the server, the compiler expects me to specify a type argument for Request and Handler. But this doesn't happen if I include hyper as a dependency in Cargo.

use hyper::server::{Handler,Request,Response};

struct SenderHandler {
    sender: Mutex<Sender<&'static str>>
}

impl Handler for SenderHandler {
    fn handle(&self, req: Request, res: Response) {
        self.sender.lock().unwrap().send("start").unwrap();
    }
}

Error: Expected 1 type arguments, found 0. I get this for both Request and Handler.

Update: I worked it out with specifying Request<OpensslStream<HttpStream>>.

Indeed, look at the docs for Handler. You receive a Request.

On Mon, Dec 5, 2016, 6:49 AM H. Almohri notifications@github.com wrote:

Thanks for the response. I'm still a bit troubled here. I downloaded the
code and added hyper as a local extern in my code (I needed this for
testing). When I want to specify a handler for the server, the compiler
expects me to specify a type argument for Request and Handler. But this
doesn't happen if I include hyper as a dependency in Cargo.

use hyper::server::{Handler,Request,Response};

struct SenderHandler {
sender: Mutex>
}

impl Handler for SenderHandler {
fn handle(&self, req: Request, res: Response) {
self.sender.lock().unwrap().send("start").unwrap();
}
}

Error: Expected 1 type arguments, found 0. I get this for both Request
and Handler.

—
You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
https://github.com/hyperium/hyper/issues/965#issuecomment-264872689, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AADJFzFZmc-qgC-2HJQNsL-73lnbX0APks5rFCRjgaJpZM4LC_o0
.

Sorry, a Response.

On Mon, Dec 5, 2016, 10:11 AM Sean McArthur sean.monstar@gmail.com wrote:

Indeed, look at the docs for Handler. You receive a Request.

On Mon, Dec 5, 2016, 6:49 AM H. Almohri notifications@github.com wrote:

Thanks for the response. I'm still a bit troubled here. I downloaded the
code and added hyper as a local extern in my code (I needed this for
testing). When I want to specify a handler for the server, the compiler
expects me to specify a type argument for Request and Handler. But this
doesn't happen if I include hyper as a dependency in Cargo.

use hyper::server::{Handler,Request,Response};

struct SenderHandler {
sender: Mutex>
}

impl Handler for SenderHandler {
fn handle(&self, req: Request, res: Response) {
self.sender.lock().unwrap().send("start").unwrap();
}
}

Error: Expected 1 type arguments, found 0. I get this for both Request
and Handler.

—
You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
https://github.com/hyperium/hyper/issues/965#issuecomment-264872689, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AADJFzFZmc-qgC-2HJQNsL-73lnbX0APks5rFCRjgaJpZM4LC_o0
.

Can you point me to where this handle function is defined? (server.handle(|_| Echo::new()).unwrap())

Was this page helpful?
0 / 5 - 0 ratings

Related issues

da2018 picture da2018  Â·  3Comments

fabioberger picture fabioberger  Â·  5Comments

mrjoe7 picture mrjoe7  Â·  4Comments

gabisurita picture gabisurita  Â·  4Comments

alex picture alex  Â·  4Comments