pub struct GatewayResponse {
pub status: u16,
pub content_type: GatewayContentType,
pub body: Vec<u8>,
pub headers: HashMap<String, String>,
pub content_length: Option<u64>,
}Expand description
Gateway response data.
§Kubo Equivalent
Corresponds to response handling in boxo/gateway/handler.go.
Fields§
§status: u16HTTP status code
content_type: GatewayContentTypeContent type
body: Vec<u8>Response body
headers: HashMap<String, String>Response headers
content_length: Option<u64>Content length (if known)
Implementations§
Source§impl GatewayResponse
impl GatewayResponse
Sourcepub fn ok(content_type: GatewayContentType, body: Vec<u8>) -> Self
pub fn ok(content_type: GatewayContentType, body: Vec<u8>) -> Self
Create a successful response.
Sourcepub fn bad_request(message: &str) -> Self
pub fn bad_request(message: &str) -> Self
Create a bad request response.
Sourcepub fn internal_error(message: &str) -> Self
pub fn internal_error(message: &str) -> Self
Create an internal error response.
Sourcepub fn with_header(self, key: &str, value: &str) -> Self
pub fn with_header(self, key: &str, value: &str) -> Self
Add a header to the response.
Sourcepub fn with_cache_control(self, immutable: bool) -> Self
pub fn with_cache_control(self, immutable: bool) -> Self
Add cache control headers.
Sourcepub fn with_ipfs_headers(self, path: &GatewayPath) -> Self
pub fn with_ipfs_headers(self, path: &GatewayPath) -> Self
Add IPFS-specific headers.
Trait Implementations§
Source§impl Clone for GatewayResponse
impl Clone for GatewayResponse
Source§fn clone(&self) -> GatewayResponse
fn clone(&self) -> GatewayResponse
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for GatewayResponse
impl RefUnwindSafe for GatewayResponse
impl Send for GatewayResponse
impl Sync for GatewayResponse
impl Unpin for GatewayResponse
impl UnwindSafe for GatewayResponse
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more