-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from community-of-python/feature/add-offline-d…
…ocs-and-cors Add offline swagger and CORS support
- Loading branch information
Showing
21 changed files
with
572 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +0,0 @@ | ||
from microbootstrap.instruments.logging_instrument import LoggingConfig | ||
from microbootstrap.instruments.opentelemetry_instrument import OpentelemetryConfig | ||
from microbootstrap.instruments.prometheus_instrument import PrometheusConfig | ||
from microbootstrap.instruments.sentry_instrument import SentryConfig | ||
|
||
|
||
__all__ = ("SentryConfig", "OpentelemetryConfig", "PrometheusConfig", "LoggingConfig") | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import annotations | ||
|
||
import pydantic | ||
|
||
from microbootstrap.instruments.base import BaseInstrumentConfig, Instrument | ||
|
||
|
||
class CorsConfig(BaseInstrumentConfig): | ||
cors_allowed_origins: list[str] = pydantic.Field(default_factory=list) | ||
cors_allowed_methods: list[str] = pydantic.Field(default_factory=list) | ||
cors_allowed_headers: list[str] = pydantic.Field(default_factory=list) | ||
cors_exposed_headers: list[str] = pydantic.Field(default_factory=list) | ||
cors_allowed_credentials: bool = False | ||
cors_allowed_origin_regex: str | None = None | ||
cors_max_age: int = 600 | ||
|
||
|
||
class CorsInstrument(Instrument[CorsConfig]): | ||
instrument_name = "Cors" | ||
ready_condition = "Provide allowed origins or regex" | ||
|
||
def is_ready(self) -> bool: | ||
return bool(self.instrument_config.cors_allowed_origins) or bool( | ||
self.instrument_config.cors_allowed_origin_regex, | ||
) | ||
|
||
@classmethod | ||
def get_config_type(cls) -> type[CorsConfig]: | ||
return CorsConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.