19 lines
659 B
TypeScript
19 lines
659 B
TypeScript
import { HttpContext } from "@adonisjs/core/http"
|
|
import { Logger } from "@adonisjs/core/logger"
|
|
import type { NextFn } from "@adonisjs/core/types/http"
|
|
|
|
/**
|
|
* The container bindings middleware binds classes to their request specific value using the container resolver.
|
|
*
|
|
* - We bind "HttpContext" class to the "context" object.
|
|
* - And bind "Logger" class to the "context.logger" object.
|
|
*/
|
|
export default class ContainerBindingsMiddleware {
|
|
public async handle(context: HttpContext, next: NextFn) {
|
|
context.containerResolver.bindValue(HttpContext, context)
|
|
context.containerResolver.bindValue(Logger, context.logger)
|
|
|
|
return next()
|
|
}
|
|
}
|