Ligare.web.application
The framework API for creating Flask and Connexion applications.
Functions
|
|
|
|
|
|
|
|
|
Register Flask blueprints and API routes |
|
Instantiate Connexion and set Flask logging options |
Classes
|
Contains an instantiated T_app application in app, and its associated FlaskInjector IoC container. |
|
|
|
Contains an instantiated Flask application and its associated application "container." This is either the same Flask instance, or an OpenAPI application. |
- class Ligare.web.application.AppInjector(app, flask_injector)[source]
Contains an instantiated T_app application in app, and its associated FlaskInjector IoC container.
- Parameters:
Generic (T_app) – An instance of Flask or FlaskApp.
FlaskInject (flask_inject) – The applications IoC container.
- __init__(app, flask_injector)
-
app:
TypeVar
(T_app
, bound=Flask
|FlaskApp
)
-
flask_injector:
FlaskInjector
- final class Ligare.web.application.ApplicationBuilder(exec)[source]
-
- build()[source]
- Return type:
CreateAppResult
[TypeVar
(T_app
, bound=Flask
|FlaskApp
)]
- use_configuration(_ApplicationBuilder__application_config_builder_callback)[source]
Execute changes to the builder’s ApplicationConfigBuilder[TAppConfig] instance.
__builder_callback can return None, or the instance of ApplicationConfigBuilder[TAppConfig] passed to its config_builder argument. This allowance is so lambdas can be used; ApplicationBuilder[T_app, TAppConfig] does not use the return value.
- Return type:
Self
- final class Ligare.web.application.ApplicationConfigBuilder[source]
-
- enable_ssm(value)[source]
Try to load config from AWS SSM. If use_filename was configured, a failed attempt to load from SSM will instead attempt to load from the configured filename. If use_filename is not configured and SSM fails, an exception is raised. If SSM succeeds, build will not load from the configured filename.
- Parameters:
value (bool) – Whether to use SSM
- Return Self:
- Return type:
Self
- protocol Ligare.web.application.ApplicationConfigBuilderCallback[source]
typing.Protocol
.Classes that implement this protocol must have the following methods / attributes:
- __call__(config_builder)[source]
A method used to configure an ApplicationConfigBuilder. Call the builder methods on config_builder to set the desired options.
Do not call `build()` as it is called by the ApplicationBuilder.
- Parameters:
config_builder (ApplicationConfigBuilder[TAppConfig])
- Return None | ApplicationConfigBuilder[TAppConfig]:
Any return value is ignored.
- Return type:
Optional
[ApplicationConfigBuilder
[TypeVar
(TAppConfig
, bound=Config
)]]
- class Ligare.web.application.CreateAppResult(flask_app, app_injector)[source]
Contains an instantiated Flask application and its associated application “container.” This is either the same Flask instance, or an OpenAPI application.
- Parameters:
Generic (flask_app) – The Flask application.
AppInjector[T_app] (app_injector) – The application’s wrapper and IoC container.
- __init__(flask_app, app_injector)
- property app: T_app
-
app_injector:
AppInjector
[TypeVar
(T_app
, bound=Flask
|FlaskApp
)]
-
flask_app:
Flask
- property injector: Injector
- run(*, import_string=None, host=None, port=None, **kwargs)[source]
Call this method to start your application. This method is partly a passthrough for uvicorn.run.
Reference https://github.com/encode/uvicorn/blob/fe3910083e3990695bc19c2ef671dd447262ae18/uvicorn/main.py#L463
- Parameters:
import_string (
Optional
[str
]) – application as import string (eg. “main:app”). This is needed to run using reload.host (
Optional
[str
]) – The hostname this application should accept requests for. If None, the value in the application’s FlaskConfig instance is used; otherwise, this parameter value is used.port (
Optional
[int
]) – The port this application should listen on for requests. If None, the value in the application’s FlaskConfig instance is used; otherwise, this parameter value is used.
- protocol Ligare.web.application.UseConfigurationCallback[source]
The callback for configuring an application’s configuration.
- Parameters:
Protocol (TAppConfig) – The AbstractConfig type to be configured.
Classes that implement this protocol must have the following methods / attributes:
- __call__(config_builder, config_overrides)[source]
Set up parameters for the application’s configuration.
- Parameters:
config_builder (ConfigBuilder[TAppConfig]) – The ConfigBuilder instance.
config_overrides (dict[str, Any]) – A dictionary of key/values that are applied over all keys that might exist in an instantiated config.
- Raises:
InvalidBuilderStateError – Upon a call to build(), the builder is misconfigured.
BuilderBuildError – Upon a call to build(), a failure occurred during the instantiation of the configuration.
Exception – Upon a call to build(), an unknown error occurred.
- Return None | ConfigBuilder[TAppConfig]:
The callback may return None or the received ConfigBuilder instance so as to support the use of lambdas. This return value is not used.
- Return type:
Optional
[ConfigBuilder
[TypeVar
(TAppConfig
, bound=Config
)]]