You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
869 B

import Module from '../Module.ts'
import Kernel from '../Kernel.ts'
import {Request} from '../../Request.ts'
import {Injectable} from '../../../../../di/src/decorator/Injection.ts'
import Config from '../../../unit/Config.ts'
/**
* Apply the default Daton headers to the outgoing response.
* @extends Module
*/
@Injectable()
export default class SetDatonHeaders extends Module {
public static register(kernel: Kernel) {
kernel.register(this).after()
}
constructor(
protected readonly config: Config,
) {
super()
}
/**
* Apply the outgoing response headers.
* @param request
*/
public async apply(request: Request): Promise<Request> {
const text = this.config.get('server.powered_by.text', 'Daton')
request.response.headers.set('X-Powered-By', text)
return request
}
}