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

Adding middleware to new programming model #61

Closed
aaronpowell opened this issue Mar 5, 2023 · 1 comment
Closed

Adding middleware to new programming model #61

aaronpowell opened this issue Mar 5, 2023 · 1 comment

Comments

@aaronpowell
Copy link
Contributor

This builds on some of the ideas proposed in Azure/azure-functions-nodejs-worker#664

Here's an idea I have for how we could do middleware:

import { app } from "@azure/functions";

app.get("home", () => ({ body: "Hello World" });

app.middleware({
  hookName: "preInvocation",
  hook: (context) => {
    //do stuff
  }
});

app.preInvocation(context => {
  //do stuff
});

app.middleware({
  hookName: "preInvocation",
  filter: "httpTrigger"
  hook: () => {}
});

app.middleware({
  hookName: "preInvocation",
  filter: (context) => context.trigger.url.contains("foo"),
  hook: () => {}
});

There's probably a bunch of additional permutations that we could support to make it more akin to the kind of middleware like you would come across in web frameworks, but also support the scenarios of having different trigger types within your application.

@aaronpowell
Copy link
Contributor Author

This is a duplicate of #7 (I really should have searched issues first 😅)

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

1 participant