Mercurial
comparison benchmark/bun-http-framework-benchmark/dev/adonis/start/kernel.ts @ 185:dfdd66825396
Merged in keep alive changes and mrjunejune changes.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Fri, 23 Jan 2026 22:22:30 -0800 |
| parents | a8976a008a9d |
| children |
comparison
equal
deleted
inserted
replaced
| 182:d6ab5921fedc | 185:dfdd66825396 |
|---|---|
| 1 /* | |
| 2 |-------------------------------------------------------------------------- | |
| 3 | Application middleware | |
| 4 |-------------------------------------------------------------------------- | |
| 5 | | |
| 6 | This file is used to define middleware for HTTP requests. You can register | |
| 7 | middleware as a `closure` or an IoC container binding. The bindings are | |
| 8 | preferred, since they keep this file clean. | |
| 9 | | |
| 10 */ | |
| 11 | |
| 12 import Server from '@ioc:Adonis/Core/Server' | |
| 13 | |
| 14 /* | |
| 15 |-------------------------------------------------------------------------- | |
| 16 | Global middleware | |
| 17 |-------------------------------------------------------------------------- | |
| 18 | | |
| 19 | An array of global middleware, that will be executed in the order they | |
| 20 | are defined for every HTTP requests. | |
| 21 | | |
| 22 */ | |
| 23 Server.middleware.register([() => import('@ioc:Adonis/Core/BodyParser')]) | |
| 24 | |
| 25 /* | |
| 26 |-------------------------------------------------------------------------- | |
| 27 | Named middleware | |
| 28 |-------------------------------------------------------------------------- | |
| 29 | | |
| 30 | Named middleware are defined as key-value pair. The value is the namespace | |
| 31 | or middleware function and key is the alias. Later you can use these | |
| 32 | alias on individual routes. For example: | |
| 33 | | |
| 34 | { auth: () => import('App/Middleware/Auth') } | |
| 35 | | |
| 36 | and then use it as follows | |
| 37 | | |
| 38 | Route.get('dashboard', 'UserController.dashboard').middleware('auth') | |
| 39 | | |
| 40 */ | |
| 41 Server.middleware.registerNamed({}) |