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.
29 lines
868 B
29 lines
868 B
import {HTTPKernelModule} from "../HTTPKernelModule";
|
|
import {Request} from "../../lifecycle/Request";
|
|
import {Injectable, Inject} from "../../../di"
|
|
import {HTTPKernel} from "../HTTPKernel";
|
|
import {Config} from "../../../service/Config";
|
|
|
|
/**
|
|
* HTTP kernel middleware that sets the `X-Powered-By` header.
|
|
*/
|
|
@Injectable()
|
|
export class PoweredByHeaderInjectionHTTPModule extends HTTPKernelModule {
|
|
public readonly executeWithBlockingWriteback = true
|
|
|
|
@Inject()
|
|
protected readonly config!: Config;
|
|
|
|
public static register(kernel: HTTPKernel) {
|
|
kernel.register(this).after()
|
|
}
|
|
|
|
public async apply(request: Request) {
|
|
if ( !this.config.get('server.poweredBy.hide', false) ) {
|
|
request.response.setHeader('X-Powered-By', this.config.get('server.poweredBy.header', 'Extollo'))
|
|
}
|
|
|
|
return request
|
|
}
|
|
}
|