Skip to content

Serve multipe routes on the same function #17

Closed
@lizzzcai

Description

@lizzzcai

Hi OpenFunction team,

I would like to request a feature of supporting multi routes in the function framework (mainly in python).

use cases:

  1. define custom health endpoint and endpoints for liveness probe and readiness probe (similar issue here Set readiness and liveness URL for function workloads in the functions-framework phase #11).
  2. support multi-functions (routes) in a function instance as it is very limited to only support one function in a function instance.
  3. dynamically extract params from the route path. for example: @app.route('/product/<name>', methods=["GET"])

example:

# health function
@app.route("/functions/<funcname>/health", methods=["GET"])
def health(request, funcname):
    return "", 200

# dynamic process function
@app.route("/functions/<funcname>:process", methods=["POST"])
def process(request, funcname):

    function = FUNCTIONS.get(funcname)
    data = dict(request.json)
    return {"output": function.process(data["input"])}

Similiar requests in gcp function-framework:

  1. Implement Declarative Function Signatures GoogleCloudPlatform/functions-framework-python#159
  2. How to serve multiple routes on the same Url : Port GoogleCloudPlatform/functions-framework-python#98

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions