@@ -34,6 +34,15 @@ class BaseConfig(ConfigDefaultTypesMixin):
3434 # https://jinja.palletsprojects.com/en/3.0.x/api/#high-level-api
3535 JINJA_TEMPLATES_OPTIONS : t .Dict [str , t .Any ] = {}
3636
37+ # Injects context to jinja templating context values
38+ TEMPLATES_CONTEXT_PROCESSORS : t .List [
39+ t .Union [str , t .Callable [[t .Union [Request ]], t .Dict [str , t .Any ]]]
40+ ] = [
41+ "ellar.core.templating.context_processors:request_context" ,
42+ "ellar.core.templating.context_processors:user" ,
43+ "ellar.core.templating.context_processors:request_state" ,
44+ ]
45+
3746 # Application route versioning scheme
3847 VERSIONING_SCHEME : BaseAPIVersioning = DefaultAPIVersioning ()
3948
@@ -56,19 +65,29 @@ class BaseConfig(ConfigDefaultTypesMixin):
5665 ALLOWED_HOSTS : t .List [str ] = ["*" ]
5766
5867 # Application middlewares
59- MIDDLEWARE : t .Sequence [Middleware ] = []
68+ MIDDLEWARE : t .Union [str , Middleware ] = [
69+ "ellar.core.middleware.trusted_host:trusted_host_middleware" ,
70+ "ellar.core.middleware.cors:cors_middleware" ,
71+ "ellar.core.middleware.errors:server_error_middleware" ,
72+ "ellar.core.middleware.versioning:versioning_middleware" ,
73+ "ellar.auth.middleware.session:session_middleware" ,
74+ "ellar.auth.middleware.auth:identity_middleware" ,
75+ "ellar.core.middleware.exceptions:exception_middleware" ,
76+ ]
6077
6178 # A dictionary mapping either integer status codes,
6279 # or exception class types onto callables which handle the exceptions.
6380 # Exception handler callables should be of the form
6481 # `handler(context:IExecutionContext, exc: Exception) -> response`
6582 # and may be either standard functions, or async functions.
66- EXCEPTION_HANDLERS : t .List [IExceptionHandler ] = []
83+ EXCEPTION_HANDLERS : t .Union [str , IExceptionHandler ] = [
84+ "ellar.core.exceptions:error_404_handler"
85+ ]
6786
6887 # Object Serializer custom encoders
69- SERIALIZER_CUSTOM_ENCODER : t .Dict [
70- t . Any , t . Callable [[ t . Any ], t . Any ]
71- ] = encoders_by_type
88+ SERIALIZER_CUSTOM_ENCODER : t .Dict [t . Any , t . Callable [[ t . Any ], t . Any ]] = (
89+ encoders_by_type
90+ )
7291
7392 STORAGE_CONFIG = dict (
7493 storages = dict (
0 commit comments