You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider to add middleware at 2 levels: app (NammathamApp) and func level.
However, NammathamApp doesn't handle request or triggers by itself, consider to add middleware for func level will be easier to manipulate.
Expected Behavior
import{initNammatham}from'@nammatham/core';import{AzureFunctionsAdapter}from'@nammatham/azure-functions';import{middleware,beforeMiddleware,afterMiddleware}from'./middlewares';constn=initNammatham.create(newAzureFunctionsAdapter());exportconstfunc=n.func;// Add middlewarefunc.use(middleware);// Add middleware before each function to be invokedfunc.useBefore(beforeMiddleware);// Add middleware after each function to be invokedfunc.useAfter(afterMiddleware);// Add middleware to a specific functionexportdefaultfunc.httpGet('hello').use(validationMiddleware).handler(async({ trigger, context })=>({body: 'OK'}))
func.httpGet('hello').use((ctx,next)=>{returnnext({
ctx,data: 'my injected data'});}).handler(async({ data })=>({body: data}));// The result will be 'my injected data'
Consider to add middleware at 2 levels:
app
(NammathamApp) andfunc
level.However,
NammathamApp
doesn't handle request or triggers by itself, consider to add middleware forfunc
level will be easier to manipulate.Expected Behavior
Related Repo:
The text was updated successfully, but these errors were encountered: