parent
94add3d471
commit
fdcd80a43e
@ -1,14 +1,17 @@
|
|||||||
import {HTTPKernelModule} from "../HTTPKernelModule";
|
import {HTTPKernelModule} from "../HTTPKernelModule";
|
||||||
import {Request} from "../../lifecycle/Request";
|
import {Request} from "../../lifecycle/Request";
|
||||||
|
import {Injectable} from "@extollo/di"
|
||||||
import {HTTPKernel} from "../HTTPKernel";
|
import {HTTPKernel} from "../HTTPKernel";
|
||||||
|
|
||||||
export class PrepareRequestHTTPModule extends HTTPKernelModule {
|
@Injectable()
|
||||||
|
export class PoweredByHeaderInjectionHTTPModule extends HTTPKernelModule {
|
||||||
public static register(kernel: HTTPKernel) {
|
public static register(kernel: HTTPKernel) {
|
||||||
kernel.register(this).first()
|
kernel.register(this).after()
|
||||||
}
|
}
|
||||||
|
|
||||||
public async apply(request: Request) {
|
public async apply(request: Request) {
|
||||||
await request.prepare()
|
// FIXME make this configurable
|
||||||
|
request.response.setHeader('X-Powered-By', 'Extollo')
|
||||||
return request
|
return request
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
import {HTTPKernelModule} from "../HTTPKernelModule";
|
||||||
|
import {Injectable, Inject} from "@extollo/di";
|
||||||
|
import {uuid_v4} from "@extollo/util";
|
||||||
|
import {HTTPKernel} from "../HTTPKernel";
|
||||||
|
import {Request} from "../../lifecycle/Request";
|
||||||
|
import {Logging} from "../../../service/Logging";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class SetSessionCookieHTTPModule extends HTTPKernelModule {
|
||||||
|
@Inject()
|
||||||
|
protected readonly logging!: Logging
|
||||||
|
|
||||||
|
public static register(kernel: HTTPKernel) {
|
||||||
|
kernel.register(this).first() // TODO make this before inject session?
|
||||||
|
}
|
||||||
|
|
||||||
|
public async apply(request: Request) {
|
||||||
|
if ( !request.cookies.has('extollo.session') ) {
|
||||||
|
const session = `${uuid_v4()}-${uuid_v4()}`
|
||||||
|
|
||||||
|
this.logging.verbose(`Starting session: ${session}`)
|
||||||
|
request.cookies.set('extollo.session', session) // FIXME allow configuring this
|
||||||
|
}
|
||||||
|
return request
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue