forked from jmug/stoatchat
chore: switch to rocket_empty [skip ci]
This commit is contained in:
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -3022,6 +3022,7 @@ dependencies = [
|
|||||||
"revolt-quark",
|
"revolt-quark",
|
||||||
"rocket",
|
"rocket",
|
||||||
"rocket_cors",
|
"rocket_cors",
|
||||||
|
"rocket_empty",
|
||||||
"rocket_okapi",
|
"rocket_okapi",
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -3061,6 +3062,7 @@ dependencies = [
|
|||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rocket",
|
"rocket",
|
||||||
|
"rocket_empty",
|
||||||
"rocket_http",
|
"rocket_http",
|
||||||
"rocket_okapi",
|
"rocket_okapi",
|
||||||
"schemars",
|
"schemars",
|
||||||
@@ -3179,6 +3181,16 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rocket_empty"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/insertish/rocket_empty?branch=rc1#5b987e4d5090d28c6658aca25f09f7458e0de0fe"
|
||||||
|
dependencies = [
|
||||||
|
"okapi",
|
||||||
|
"rocket",
|
||||||
|
"rocket_okapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rocket_http"
|
name = "rocket_http"
|
||||||
version = "0.5.0-rc.1"
|
version = "0.5.0-rc.1"
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ mobc = { version = "0.7.3" }
|
|||||||
mobc-redis = { version = "0.7.0", default-features = false, features = ["async-std-comp"] }
|
mobc-redis = { version = "0.7.0", default-features = false, features = ["async-std-comp"] }
|
||||||
|
|
||||||
# web
|
# web
|
||||||
|
rocket_empty = { git = "https://github.com/insertish/rocket_empty", branch = "rc1" }
|
||||||
rocket = { version = "0.5.0-rc.1", default-features = false, features = ["json"] }
|
rocket = { version = "0.5.0-rc.1", default-features = false, features = ["json"] }
|
||||||
mongodb = { version = "1.2.2", features = ["async-std-runtime"], default-features = false }
|
mongodb = { version = "1.2.2", features = ["async-std-runtime"], default-features = false }
|
||||||
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", rev = "5843861a88958c16bfaa0b40f0d8910772bcd2f6" }
|
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", rev = "5843861a88958c16bfaa0b40f0d8910772bcd2f6" }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ edition = "2021"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
mongo = [ "mongodb" ]
|
mongo = [ "mongodb" ]
|
||||||
rocket_impl = [ "rocket" ]
|
rocket_impl = [ "rocket", "rocket_empty" ]
|
||||||
test = [ "async-std", "mongo", "mongodb/async-std-runtime", "rocket_impl", "rauth" ]
|
test = [ "async-std", "mongo", "mongodb/async-std-runtime", "rocket_impl", "rauth" ]
|
||||||
default = [ "test" ]
|
default = [ "test" ]
|
||||||
|
|
||||||
@@ -66,6 +66,7 @@ web-push = "0.7.2"
|
|||||||
rauth = { optional = true, git = "https://github.com/insertish/rauth", rev = "001a9698c56cea79e69e4ae71d7bc2cb48aec1a6" }
|
rauth = { optional = true, git = "https://github.com/insertish/rauth", rev = "001a9698c56cea79e69e4ae71d7bc2cb48aec1a6" }
|
||||||
rocket = { optional = true, version = "=0.5.0-rc.1", default-features = false, features = ["json"] }
|
rocket = { optional = true, version = "=0.5.0-rc.1", default-features = false, features = ["json"] }
|
||||||
rocket_http = { optional = true, version = "=0.5.0-rc.1" }
|
rocket_http = { optional = true, version = "=0.5.0-rc.1" }
|
||||||
|
rocket_empty = { optional = true, git = "https://github.com/insertish/rocket_empty", branch = "rc1" }
|
||||||
|
|
||||||
# Sentry
|
# Sentry
|
||||||
sentry = "0.25.0"
|
sentry = "0.25.0"
|
||||||
|
|||||||
@@ -39,9 +39,12 @@ pub use permissions::defn::*;
|
|||||||
pub use permissions::{get_relationship, perms};
|
pub use permissions::{get_relationship, perms};
|
||||||
|
|
||||||
pub use util::r#ref::Ref;
|
pub use util::r#ref::Ref;
|
||||||
pub use util::result::{EmptyResponse, Error, Result};
|
pub use util::result::{Error, Result};
|
||||||
pub use util::variables;
|
pub use util::variables;
|
||||||
|
|
||||||
|
#[cfg(feature = "rocket_impl")]
|
||||||
|
pub use rocket_empty::EmptyResponse;
|
||||||
|
|
||||||
#[cfg(feature = "rocket_impl")]
|
#[cfg(feature = "rocket_impl")]
|
||||||
use rocket::State;
|
use rocket::State;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use okapi::openapi3::{self, RefOr, SchemaObject};
|
use okapi::openapi3::{self, SchemaObject};
|
||||||
use rocket::{
|
use rocket::{
|
||||||
http::{ContentType, Status},
|
http::{ContentType, Status},
|
||||||
response::{self, Responder},
|
response::{self, Responder},
|
||||||
@@ -116,21 +116,9 @@ impl Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Empty 204 HTTP Response
|
|
||||||
pub struct EmptyResponse;
|
|
||||||
|
|
||||||
/// Result type with custom Error
|
/// Result type with custom Error
|
||||||
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
||||||
|
|
||||||
// ! FIXME: #[cfg]
|
|
||||||
impl<'r> Responder<'r, 'static> for EmptyResponse {
|
|
||||||
fn respond_to(self, _: &'r Request<'_>) -> response::Result<'static> {
|
|
||||||
Response::build()
|
|
||||||
.status(rocket::http::Status { code: 204 })
|
|
||||||
.ok()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// HTTP response builder for Error enum
|
/// HTTP response builder for Error enum
|
||||||
impl<'r> Responder<'r, 'static> for Error {
|
impl<'r> Responder<'r, 'static> for Error {
|
||||||
fn respond_to(self, _: &'r Request<'_>) -> response::Result<'static> {
|
fn respond_to(self, _: &'r Request<'_>) -> response::Result<'static> {
|
||||||
@@ -241,24 +229,3 @@ impl rocket_okapi::response::OpenApiResponderInner for Error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rocket_okapi::response::OpenApiResponderInner for EmptyResponse {
|
|
||||||
fn responses(
|
|
||||||
_gen: &mut rocket_okapi::gen::OpenApiGenerator,
|
|
||||||
) -> std::result::Result<openapi3::Responses, rocket_okapi::OpenApiError> {
|
|
||||||
let mut responses = okapi::Map::new();
|
|
||||||
|
|
||||||
responses.insert(
|
|
||||||
"204".to_string(),
|
|
||||||
RefOr::Object(openapi3::Response {
|
|
||||||
description: "Success".to_string(),
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(openapi3::Responses {
|
|
||||||
responses,
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user