Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve multipe routes on the same function #17

Closed
lizzzcai opened this issue Apr 26, 2022 · 2 comments
Closed

Serve multipe routes on the same function #17

lizzzcai opened this issue Apr 26, 2022 · 2 comments
Assignees

Comments

@lizzzcai
Copy link
Member

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
@benjaminhuo
Copy link
Member

This is a good requirement, thanks @lizzzcai

@benjaminhuo
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants