rs_server_catalog/middleware/catalog_middleware.md
A BaseHTTPMiddleware to handle the user multi catalog.
The stac-fastapi software doesn't handle multi catalog. In the rs-server we need to handle user-based catalogs.
The rs-server uses only one catalog but the collections are prefixed by the user name. The middleware is used to hide this mechanism.
The middleware: * redirect the user-specific request to the common stac api endpoint * modifies the request to add the user prefix in the collection name * modifies the response to remove the user prefix in the collection name * modifies the response to update the links.
CatalogMiddleware
Bases: BaseHTTPMiddleware
The user catalog middleware.
Source code in docs/rs-server/services/catalog/rs_server_catalog/middleware/catalog_middleware.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
dispatch(request, call_next)
async
Redirect the user catalog specific endpoint and adapt the response content.
Source code in docs/rs-server/services/catalog/rs_server_catalog/middleware/catalog_middleware.py
61 62 63 64 65 66 67 68 69 70 71 72 | |
UserCatalog
The user catalog middleware handler.
Source code in docs/rs-server/services/catalog/rs_server_catalog/middleware/catalog_middleware.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
__init__(client)
Constructor, called from the middleware
Source code in docs/rs-server/services/catalog/rs_server_catalog/middleware/catalog_middleware.py
78 79 80 81 | |
dispatch(request, call_next)
async
Redirect the user catalog specific endpoint and adapt the response content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
Initial request |
required |
call_next
|
RequestResponseEndpoint
|
next call to apply |
required |
Returns:
| Name | Type | Description |
|---|---|---|
response |
Response
|
Response to the current request |
Source code in docs/rs-server/services/catalog/rs_server_catalog/middleware/catalog_middleware.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
log_http_exception(*args, **kwargs)
Log error and return an HTTP exception to be raised by the caller
Source code in docs/rs-server/services/catalog/rs_server_catalog/middleware/catalog_middleware.py
53 54 55 | |