Expand description
§GoodCam Device Proxy
This library simplifies creating HTTP proxies that can be used to communicate with GoodCam devices in various networks. GoodCam devices contain a built-in client that can be configured to connect automatically to a given proxy. Once connected, the devices will wait for incoming HTTP requests. The proxy simply forwards incoming HTTP requests to the connected devices.
§Usage example
See the examples
directory in the root of this repository for a
ready-to-use example.
ⓘ
use gcdevproxy::{
async_trait::async_trait,
auth::BasicAuthorization,
http::{Body, Request},
ClientHandlerResult, DeviceHandlerResult, Error, RequestHandler,
};
struct MyRequestHandler;
#[async_trait]
impl RequestHandler for MyRequestHandler {
async fn handle_device_request(
&self,
authorization: BasicAuthorization,
) -> Result<DeviceHandlerResult, Error> {
...
}
async fn handle_client_request(
&self,
request: Request<Body>,
) -> Result<ClientHandlerResult, Error> {
...
}
}
let mut builder = ProxyBuilder::new();
builder
.hostname(hostname)
.http_bind_address(SocketAddr::from((Ipv4Addr::UNSPECIFIED, 8080)));
builder
.build(MyRequestHandler)
.await
.unwrap()
.await
.unwrap();
Re-exports§
pub use async_trait;
pub use hyper;
pub use hyper::http;
Modules§
- auth
- Authorization types.
Structs§
- Body
- HTTP message body.
- Connection
Info - Connection info.
- Error
- Error type.
- Proxy
- GoodCam device proxy.
- Proxy
Builder - Proxy builder.
- Proxy
Handle - Proxy handle.
- Request
Handler Adapter - Adapter to make a
RequestHandler
from a givenBlockingRequestHandler
.
Enums§
- Client
Handler Result - Possible results of a client handler.
- Device
Handler Result - Possible results of a device connection handler.
Traits§
- Blocking
Request Handler - Blocking version of the request handler trait.
- Request
Handler - Common trait for proxy request handlers.