Unstructured-IO / unstructured-api-tools

Apache License 2.0
28 stars 10 forks source link

Add duplicate routes with semver major version, only #147

Closed cragwolfe closed 1 year ago

cragwolfe commented 1 year ago

Currently,

Routes are created such as @router.post("/test-project/v1.2.3/process-file-1") here which is great.

However, the web server should also handle requests to the major-semver-version-only of the path e.g. /test-project/v1/process-file-1 the same way it handles requests to /test-project/v1.2.3/process-file-1 . I haven't found a great way to do this with FastAPI in a Google search or via the LLM's, so I think it would be fine to just wrap the entire block in the jinja template in a two-element for loop -- this is just code generation after all.

Alternatively, something like this is also probably OK:

async def process_file(request: Request):
    # your common logic here
    return {"message": "File processed successfully"}

@router.post("/test-project/v1.2.3/process-file-1")
async def pipeline_1(request: Request):
    return await process_file(request)

@router.post("/test-project/v1/process-file-1")
async def pipeline_2(request: Request):
    return await process_file(request)

Definition of Done