Skip to main content

bytes_response

Function bytes_response 

Source
pub fn bytes_response(
    status: StatusCode,
    content_type: &str,
    body: Bytes,
) -> Response
Expand description

Build a Response from a status, content type, and raw bytes.

Covers the common “I have bytes and a content type” case (media segments, generated files, opaque blobs) without hand-rolling a builder. Sets Content-Type and Content-Length.

use arcly_http::http::{bytes_response, Bytes, StatusCode};
let r = bytes_response(StatusCode::OK, "application/octet-stream", Bytes::from_static(b"hi"));
assert_eq!(r.status(), StatusCode::OK);