diff options
| author | Fuwn <[email protected]> | 2022-03-27 06:03:33 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-03-27 06:03:33 +0000 |
| commit | 97884a183f378fd996029cde769df2e974fff1eb (patch) | |
| tree | bf270166bffb4622e3bb2e027707b71b05e2501d /src/response.rs | |
| parent | refactor(tokio): reexport main (diff) | |
| download | windmark-97884a183f378fd996029cde769df2e974fff1eb.tar.xz windmark-97884a183f378fd996029cde769df2e974fff1eb.zip | |
feat(response): respond with file
Diffstat (limited to 'src/response.rs')
| -rw-r--r-- | src/response.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/response.rs b/src/response.rs index c7dbf88..d89dbf2 100644 --- a/src/response.rs +++ b/src/response.rs @@ -16,10 +16,11 @@ // Copyright (C) 2022-2022 Fuwn <[email protected]> // SPDX-License-Identifier: GPL-3.0-only -pub enum Response { +pub enum Response<'a> { Input(String), SensitiveInput(String), Success(String), + SuccessFile(&'a [u8]), TemporaryRedirect(String), PermanentRedirect(String), TemporaryFailure(String), @@ -38,7 +39,7 @@ pub enum Response { } pub(crate) fn to_value_set_status( - response: Response, + response: Response<'_>, status: &mut i32, ) -> String { match response { @@ -57,6 +58,11 @@ pub(crate) fn to_value_set_status( value } + Response::SuccessFile(value) => { + *status = 21; // Internal status code, not real. + + String::from_utf8(value.to_vec()).unwrap() + } Response::TemporaryRedirect(value) => { *status = 30; |