Reference¶
dsg_lib.robyn_functions.default_endpoints
¶
Default endpoints for a Robyn application, mirroring
dsg_lib.fastapi_functions.default_endpoints.
Example:
from robyn import Robyn
from dsg_lib.robyn_functions import default_endpoints
app = Robyn(__file__)
config = [
{"bot": "GPTBot", "allow": False},
{"bot": "Googlebot", "allow": True},
]
app.include_router(default_endpoints.create_default_router(config))
# GET /robots.txt -> text/plain robots.txt built from config
Author: Mike Ryan License: MIT
create_default_router(config, prefix='', tags=None)
¶
Creates a Robyn SubRouter with default endpoints, including a configurable robots.txt.
Unlike FastAPI's app.include_router(router, prefix=...), Robyn's
include_router takes no prefix, so the prefix and OpenAPI tags are set
here instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
List[Dict[str, Union[str, bool]]]
|
A list of dictionaries
specifying which bots are allowed or disallowed, e.g.
|
required |
prefix
|
str
|
Path prefix for the routes. Defaults to |
''
|
tags
|
Optional[List[str]]
|
OpenAPI tags applied to every route. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
SubRouter |
SubRouter
|
A Robyn SubRouter with the default endpoints. Register it |
SubRouter
|
with |
Source code in dsg_lib/robyn_functions/default_endpoints.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |