pub trait Application {
    type Routes;

Show 24 methods // Required methods fn register(self, routes: Self::Routes) -> Self; fn run_with<T: AsyncScheduler + Send + 'static>(self, scheduler: T); // Provided methods fn boot() -> Self where Self: Default { ... } fn boot_with<F>(init: F) -> Self where Self: Default, F: FnOnce(&'static State<Map>) { ... } fn register_with(self, server_tag: ServerTag, routes: Self::Routes) -> Self where Self: Sized { ... } fn register_debug(self, routes: Self::Routes) -> Self where Self: Sized { ... } fn sysinfo() -> Map { ... } fn openapi() -> OpenApi { ... } fn shared_state() -> &'static State<Map> { ... } fn env() -> &'static Env { ... } fn config() -> &'static Table { ... } fn state_data() -> &'static Map { ... } fn name() -> &'static str { ... } fn version() -> &'static str { ... } fn domain() -> &'static str { ... } fn project_dir() -> &'static PathBuf { ... } fn secret_key() -> &'static [u8] { ... } fn shared_dir(name: &str) -> PathBuf { ... } fn spawn<T>(self, scheduler: T) -> Self where Self: Sized, T: Scheduler + Send + 'static { ... } fn run(self) where Self: Sized { ... } async fn load() { ... } async fn shutdown() { ... } async fn fetch( resource: &str, options: Option<&Map> ) -> Result<Response, Error> { ... } async fn fetch_json<T: DeserializeOwned>( resource: &str, options: Option<&Map> ) -> Result<T, Error> { ... }
}
Expand description

Application interfaces.

Required Associated Types§

source

type Routes

Routes.

Required Methods§

source

fn register(self, routes: Self::Routes) -> Self

Registers default routes.

source

fn run_with<T: AsyncScheduler + Send + 'static>(self, scheduler: T)

Runs the application with an optional scheduler for async jobs.

Provided Methods§

source

fn boot() -> Self
where Self: Default,

Boots the application. It also initializes the required directories and setups the default secret key, the tracing subscriber, the metrics exporter and a global HTTP client.

source

fn boot_with<F>(init: F) -> Self
where Self: Default, F: FnOnce(&'static State<Map>),

Boots the application with a custom initialization.

source

fn register_with(self, server_tag: ServerTag, routes: Self::Routes) -> Self
where Self: Sized,

Registers routes with a server tag.

source

fn register_debug(self, routes: Self::Routes) -> Self
where Self: Sized,

Registers routes for debugger.

source

fn sysinfo() -> Map

Gets the system’s information.

source

fn openapi() -> OpenApi

Gets the OpenAPI document.

source

fn shared_state() -> &'static State<Map>

Returns a reference to the shared application state.

source

fn env() -> &'static Env

Returns the application env.

source

fn config() -> &'static Table

Returns a reference to the shared application config.

source

fn state_data() -> &'static Map

Returns a reference to the shared application state data.

source

fn name() -> &'static str

Returns the application name.

source

fn version() -> &'static str

Returns the application version.

source

fn domain() -> &'static str

Returns the domain for the application.

source

fn project_dir() -> &'static PathBuf

Returns the project directory for the application.

source

fn secret_key() -> &'static [u8]

Returns the secret key for the application. It should have at least 64 bytes.

Note

This should only be used for internal services. Do not expose it to external users.

source

fn shared_dir(name: &str) -> PathBuf

Returns the shared directory with the specific name, which is defined in the dirs table.

source

fn spawn<T>(self, scheduler: T) -> Self
where Self: Sized, T: Scheduler + Send + 'static,

Spawns a new thread to run cron jobs.

source

fn run(self)
where Self: Sized,

Runs the application with a default job scheduler.

source

async fn load()

Loads resources after booting the application.

source

async fn shutdown()

Handles the graceful shutdown.

source

async fn fetch(resource: &str, options: Option<&Map>) -> Result<Response, Error>

Makes an HTTP request to the provided resource using reqwest.

source

async fn fetch_json<T: DeserializeOwned>( resource: &str, options: Option<&Map> ) -> Result<T, Error>

Makes an HTTP request to the provided resource and deserializes the response body via JSON.

Object Safety§

This trait is not object safe.

Implementors§