url root and ip now optional'
This commit is contained in:
parent
ce52997bed
commit
3726a28286
8 changed files with 199 additions and 118 deletions
|
@ -1,9 +1,11 @@
|
|||
use std::{error::Error, str::FromStr, time::Duration};
|
||||
use std::{error::Error, time::Duration};
|
||||
|
||||
use ezhttp::{client::{ClientBuilder, RequestBuilder}, request::URL};
|
||||
use ezhttp::{client::{ClientBuilder, RequestBuilder}, request::IntoURL};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
dbg!("https://meex.lol/dku?key=value#hex_id".to_url().unwrap().to_string());
|
||||
|
||||
let client = ClientBuilder::new()
|
||||
.ssl_verify(false)
|
||||
.connect_timeout(Duration::from_secs(5))
|
||||
|
@ -12,7 +14,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||
.header("User-Agent", "EzHttp/0.1.0")
|
||||
.build();
|
||||
|
||||
let request = RequestBuilder::get(URL::from_str("https://meex.lol/dku?key=value#hex_id")?).build();
|
||||
let request = RequestBuilder::get("https://meex.lol/dku?key=value#hex_id");
|
||||
|
||||
println!("request: {:?}", &request);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ impl EzSite {
|
|||
#[async_trait]
|
||||
impl HttpServer for EzSite {
|
||||
async fn on_request(&self, req: &HttpRequest) -> Option<Box<dyn Sendable>> {
|
||||
println!("{} > {} {}", req.addr, req.method, req.url.to_path_string());
|
||||
println!("{} > {} {}", req.addr?, req.method, req.url.to_string());
|
||||
|
||||
if let Some(resp) = self.get_main_page(req).await {
|
||||
Some(resp.as_box())
|
||||
|
|
|
@ -6,7 +6,7 @@ struct EzSite(String);
|
|||
#[async_trait]
|
||||
impl HttpServer for EzSite {
|
||||
async fn on_request(&self, req: &HttpRequest) -> Option<Box<dyn Sendable>> {
|
||||
println!("{} > {} {}", req.addr, req.method, req.url.to_path_string());
|
||||
println!("{} > {} {}", req.addr?, req.method, req.url.to_string());
|
||||
|
||||
if req.url.path == "/" {
|
||||
Some(HttpResponse::new(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue