Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/BenLocal/rszlm
Browse files Browse the repository at this point in the history
  • Loading branch information
BenLocal committed Aug 6, 2024
2 parents 3759d7a + 5216332 commit 4b64e20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ workspace = { members = ["rszlm-sys"] }

[package]
name = "rszlm"
version = "0.1.7"
version = "0.1.9"
edition = "2021"
authors = ["shiben. <benshi0v0@gmail.com>"]
description = "ZLMediaKit rust api"
Expand Down
15 changes: 13 additions & 2 deletions examples/server.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::str::FromStr;

use axum::response::IntoResponse;
use axum::{body::Body, routing::get, Router};
Expand Down Expand Up @@ -269,12 +270,22 @@ fn start_zlm_background(
};

let uri = format!("http://127.0.0.1:{}{}", AXUM_PORT, path_query);
if let Ok(req) = hyper::Request::builder()
let headers = msg.parser.headers();

if let Ok(mut req) = hyper::Request::builder()
.method(msg.parser.method().as_str())
.uri(uri)
.body(Body::from(msg.parser.body()))
{
// TODO copy request headers
if !headers.is_empty() {
for (k, v) in headers {
req.headers_mut().insert(
hyper::http::HeaderName::from_str(&k).unwrap(),
hyper::http::HeaderValue::from_str(&v).unwrap(),
);
}
}

let resp = runtime.block_on(async move {
CLIENT
.request(req)
Expand Down

0 comments on commit 4b64e20

Please sign in to comment.