api/router.rs: add new 'protected' flag to ApiMethod

This commit is contained in:
Dietmar Maurer 2019-01-28 17:18:42 +01:00
parent 5bb3398171
commit 4e4df8e2f0
1 changed files with 9 additions and 0 deletions

View File

@ -39,6 +39,7 @@ type ApiHandlerFn = fn(Value, &ApiMethod, &mut dyn RpcEnvironment) -> Result<Val
type ApiAsyncHandlerFn = fn(Parts, Body, Value, &ApiAsyncMethod, &mut dyn RpcEnvironment) -> Result<BoxFut, Error>; type ApiAsyncHandlerFn = fn(Parts, Body, Value, &ApiAsyncMethod, &mut dyn RpcEnvironment) -> Result<BoxFut, Error>;
pub struct ApiMethod { pub struct ApiMethod {
pub protected: bool,
pub parameters: ObjectSchema, pub parameters: ObjectSchema,
pub returns: Arc<Schema>, pub returns: Arc<Schema>,
pub handler: ApiHandlerFn, pub handler: ApiHandlerFn,
@ -51,6 +52,7 @@ impl ApiMethod {
parameters, parameters,
handler, handler,
returns: Arc::new(Schema::Null), returns: Arc::new(Schema::Null),
protected: false,
} }
} }
@ -60,6 +62,13 @@ impl ApiMethod {
self self
} }
pub fn protected(mut self, protected: bool) -> Self {
self.protected = protected;
self
}
} }
pub struct ApiAsyncMethod { pub struct ApiAsyncMethod {