diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2022-09-20 00:31:13 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-20 00:31:13 +0000 |
commit | 5a68df14385c730d6087a845250d28adab3c3751 (patch) | |
tree | 62789ab21c8c6a41b2865ae4bf69aed3f87ac644 /src/errors.rs | |
parent | Add CHANGELOG for plain text READMEs (diff) | |
parent | Merge branch 'svenstaro:master' into restrict-upload-dir (diff) | |
download | miniserve-5a68df14385c730d6087a845250d28adab3c3751.tar.gz miniserve-5a68df14385c730d6087a845250d28adab3c3751.zip |
Merge pull request #858 from jonasdiemer/restrict-upload-dir
Added option restrict-upload-dir
Diffstat (limited to 'src/errors.rs')
-rw-r--r-- | src/errors.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/errors.rs b/src/errors.rs index b2ed459..06569d3 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -22,6 +22,10 @@ pub enum ContextualError { #[error("File already exists, and the overwrite_files option has not been set")] DuplicateFileError, + /// Upload not allowed + #[error("Upload not allowed to this directory")] + UploadForbiddenError, + /// Any error related to an invalid path (failed to retrieve entry name, unexpected entry type, etc) #[error("Invalid path\ncaused by: {0}")] InvalidPathError(String), @@ -88,6 +92,8 @@ impl ResponseError for ContextualError { Self::InsufficientPermissionsError(_) => StatusCode::FORBIDDEN, Self::InvalidHttpCredentials => StatusCode::UNAUTHORIZED, Self::InvalidHttpRequestError(_) => StatusCode::BAD_REQUEST, + Self::DuplicateFileError => StatusCode::FORBIDDEN, + Self::UploadForbiddenError => StatusCode::FORBIDDEN, _ => StatusCode::INTERNAL_SERVER_ERROR, } } |