pub struct Response {Show 13 fields
pub request: Request,
pub status: Status,
pub headers: JsonValue,
pub cookies: JsonValue,
pub body: Vec<u8>,
pub stream_id: u32,
pub key: String,
pub version: String,
pub factory: fn(out: Websocket) -> Box<dyn Handler>,
pub allow_origins: Vec<&'static str>,
pub allow_methods: Vec<&'static str>,
pub allow_headers: Vec<&'static str>,
pub content_type: ContentType,
}Expand description
响应
Fields§
§request: Request§status: Status§headers: JsonValue§body: Vec<u8>消息体
stream_id: u32HTTP2 使用
key: Stringws 通信密钥
version: Stringws 版本
factory: fn(out: Websocket) -> Box<dyn Handler>§allow_origins: Vec<&'static str>允许来源
allow_methods: Vec<&'static str>允许方法
allow_headers: Vec<&'static str>允许请求头
content_type: ContentType消息体类型
Implementations§
Source§impl Response
impl Response
pub fn new( request: &Request, factory: fn(out: Websocket) -> Box<dyn Handler>, ) -> Self
pub fn handle(self) -> Result<()>
pub fn status(&mut self, code: u16) -> &mut Self
pub fn header(&mut self, key: &str, value: &str) -> &mut Self
Sourcepub fn download(&mut self, filename: &Path) -> &mut Self
pub fn download(&mut self, filename: &Path) -> &mut Self
下载 返回
§Panics
This function will panic if:
filename.extension()returnsNone- The extension cannot be converted to a valid UTF-8 string
- The filename cannot be converted to a valid UTF-8 string
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
Blanket Implementations§
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