diff --git a/docs/authentication.md b/docs/authentication.md index 1b59c64..c3ce905 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -53,15 +53,19 @@ FastAPI is built on Starlette, so a FastAPI app can be configured with middlewar As described in the [environment variable reference](environment.md) and [contribution guide](contributing.md), when starting the inboard server, the environment variables `BASIC_AUTH_USERNAME` and `BASIC_AUTH_PASSWORD` can be set. The values of these variables can then be passed in with client requests to authenticate. +Server: + ```sh -# server docker pull ghcr.io/br3ndonland/inboard docker run -d -p 80:80 \ -e "BASIC_AUTH_USERNAME=test_user" \ -e "BASIC_AUTH_PASSWORD=r4ndom_bUt_memorable" \ ghcr.io/br3ndonland/inboard +``` -# client: https://httpie.io/ +Client (using [HTTPie](https://httpie.io/)): + +```sh http :80/health -a "test_user":"r4ndom_bUt_memorable" ``` diff --git a/docs/docker.md b/docs/docker.md index e31d1fa..cc2d6a3 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -10,7 +10,7 @@ Please see [inboard Git tags](https://github.com/br3ndonland/inboard/tags), [inb !!! example "Example Docker tags" - ```sh + ```{ .sh .no-copy } # Pull latest FastAPI image (Docker automatically appends the `latest` tag) docker pull ghcr.io/br3ndonland/inboard diff --git a/docs/environment.md b/docs/environment.md index 6ffbb5d..7652de9 100644 --- a/docs/environment.md +++ b/docs/environment.md @@ -262,14 +262,14 @@ The idea here is to allow a catch-all Uvicorn config variable in the spirit of ` !!! example "Example of how to format `UVICORN_CONFIG_OPTIONS` as valid JSON" ```py - >>> import json - >>> import os - >>> uvicorn_config_dict = dict(host="0.0.0.0", port=80, log_config=None, log_level="info", reload=False) - >>> json.dumps(uvicorn_config_dict) - '{"host": "0.0.0.0", "port": 80, "log_config": null, "log_level": "info", "reload": false}' - >>> os.environ["UVICORN_CONFIG_OPTIONS"] = json.dumps(uvicorn_config_dict) - >>> json.loads(os.environ["UVICORN_CONFIG_OPTIONS"]) == uvicorn_config_dict - True + import json + import os + uvicorn_config_dict = dict(host="0.0.0.0", port=80, log_config=None, log_level="info", reload=False) + json.dumps(uvicorn_config_dict) + # '{"host": "0.0.0.0", "port": 80, "log_config": null, "log_level": "info", "reload": false}' + os.environ["UVICORN_CONFIG_OPTIONS"] = json.dumps(uvicorn_config_dict) + json.loads(os.environ["UVICORN_CONFIG_OPTIONS"]) == uvicorn_config_dict + # True ``` !!! warning @@ -279,11 +279,11 @@ The idea here is to allow a catch-all Uvicorn config variable in the spirit of ` In the example below, `reload` will be passed through with the correct type (because it was formatted with the correct JSON type initially), but `access_log` will have an incorrect type (because it was formatted as a string instead of as a Boolean). ```py - >>> import json - >>> import os - >>> os.environ["UVICORN_CONFIG_OPTIONS_INCORRECT"] = '{"access_log": "false", "reload": true}' - >>> json.loads(os.environ["UVICORN_CONFIG_OPTIONS_INCORRECT"]) - {'access_log': "false", 'reload': True} + import json + import os + os.environ["UVICORN_CONFIG_OPTIONS_INCORRECT"] = '{"access_log": "false", "reload": true}' + json.loads(os.environ["UVICORN_CONFIG_OPTIONS_INCORRECT"]) + # {'access_log': "false", 'reload': True} ``` ## Logging @@ -329,7 +329,7 @@ The idea here is to allow a catch-all Uvicorn config variable in the spirit of ` !!!example "Example log message in different formats" - ```log + ```{ .log .no-copy } # simple INFO Started server process [19012] diff --git a/docs/logging.md b/docs/logging.md index 0b8176a..43633d3 100644 --- a/docs/logging.md +++ b/docs/logging.md @@ -18,14 +18,17 @@ One of the primary use cases for log message filters is health checks. When appl The `LOG_FILTERS` environment variable can be used to specify filters as a comma-separated string, like `LOG_FILTERS="/health, /heartbeat"`. To then add the filters to a class instance, the `LogFilter.set_filters()` method can produce the set of filters from the environment variable value. -```py +```{ .sh .no-copy } # start a REPL session in a venv in which inboard is installed .venv ❯ python ->>> import os ->>> import inboard ->>> os.environ["LOG_FILTERS"] = "/health, /heartbeat" ->>> inboard.LogFilter.set_filters() -{'/heartbeat', '/health'} +``` + +```py +import os +import inboard +os.environ["LOG_FILTERS"] = "/health, /heartbeat" +inboard.LogFilter.set_filters() +# {'/heartbeat', '/health'} ``` inboard will do this automatically by reading the `LOG_FILTERS` environment variable. @@ -49,7 +52,7 @@ docker run \ docker logs -f $(docker ps -q -n 1) ``` -```log +```{ .log .no-copy } DEBUG Logging dict config loaded from inboard.logging_conf. DEBUG Checking for pre-start script. DEBUG No pre-start script specified. @@ -73,7 +76,7 @@ Make a request to an endpoint that should be logged, using an HTTP client like [ The request will be logged through `uvicorn.access`: -```log +```{ .log .no-copy } INFO 172.17.0.1:65026 - "GET / HTTP/1.1" 200 ``` diff --git a/mkdocs.yml b/mkdocs.yml index a3973aa..6e0b9a7 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -26,6 +26,7 @@ site_url: "" theme: favicon: assets/images/favicon.png features: + - content.code.copy - header.autohide - navigation.instant - navigation.top