Middleware

Middleware behaves the same as middlewares in traditional web frameworks. It wraps around the next middleware or handler, access the request data, modify or alter the response data. The middleware ordering in the stack is first in last out.

To declare a middleware, use declare middleware.

declare middleware print(label?: String)

Middleware implementation

To implement custom handlers, use server APIs. See:

Installation

Middlewares can be applied to namespaces, while the middlewares stack inherit items from the parent namespace, too.

This code snippet demostrates how to install middlewares to a namespace's middleware stack.

middlewares [
  middleware1(arg1: "arg1"), 
  middleware2
]