Exemplo n.º 1
0
async def get_index(config: Config = Depends(config_dependency)) -> Metadata:
    """GET ``/`` (the app's internal root).

    By convention, this endpoint returns only the application's metadata.
    """
    return get_metadata(package_name="gafaelfawr",
                        application_name=config.safir.name)
Exemplo n.º 2
0
async def test_get_metadata() -> None:
    """Test get_metadata in normal usage."""
    data = get_metadata(package_name="safir", application_name="testapp")
    assert data.name == "testapp"
    assert data.version
    assert data.description
    assert data.repository_url == "https://github.com/lsst-sqre/safir"
    assert data.documentation_url == "https://safir.lsst.io"
Exemplo n.º 3
0
async def get_index() -> Metadata:
    """GET ``/`` (the app's internal root).

    By convention, this endpoint returns only the application's metadata.
    """
    return get_metadata(
        package_name="example",
        application_name=config.name,
    )
Exemplo n.º 4
0
async def get_index(
    moneypenny: Moneypenny = Depends(moneypenny_dependency),
) -> Index:
    """GET ``/moneypenny/`` (the app's external root).

    Customize this handler to return whatever the top-level resource of your
    application should return. For example, consider listing key API URLs.
    When doing so, also change or customize the response model in
    `moneypenny.models.Index`.

    By convention, the root of the external API includes a field called
    ``metadata`` that provides the same Safir-generated metadata as the
    internal root endpoint.
    """
    metadata = get_metadata(
        package_name="moneypenny",
        application_name=config.name,
    )
    return Index(quip=moneypenny.quip().strip(), metadata=metadata)
Exemplo n.º 5
0
async def get_index(
        logger: BoundLogger = Depends(logger_dependency), ) -> Index:
    """GET ``/example/`` (the app's external root).

    Customize this handler to return whatever the top-level resource of your
    application should return. For example, consider listing key API URLs.
    When doing so, also change or customize the response model in
    `example.models.Index`.

    By convention, the root of the external API includes a field called
    ``metadata`` that provides the same Safir-generated metadata as the
    internal root endpoint.
    """
    # There is no need to log simple requests since uvicorn will do this
    # automatically, but this is included as an example of how to use the
    # logger for more complex logging.
    logger.info("Request for application metadata")

    metadata = get_metadata(
        package_name="example",
        application_name=config.name,
    )
    return Index(metadata=metadata)