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.
28 lines
772 B
28 lines
772 B
import ResponseFactory from './ResponseFactory.ts'
|
|
import {Request} from '../Request.ts'
|
|
import {HTTPStatus} from '../../const/http.ts'
|
|
|
|
/**
|
|
* Response factory that sends a temporary redirect.
|
|
* @extends ResponseFactory
|
|
*/
|
|
export default class TemporaryRedirectResponseFactory extends ResponseFactory {
|
|
protected target_status: HTTPStatus = HTTPStatus.TEMPORARY_REDIRECT
|
|
|
|
constructor(
|
|
/**
|
|
* Destination to redirect the user to.
|
|
* @type string
|
|
*/
|
|
public readonly destination: string,
|
|
) {
|
|
super()
|
|
}
|
|
|
|
public async write(request: Request): Promise<Request> {
|
|
request = await super.write(request)
|
|
request.response.headers.set('Location', this.destination)
|
|
return request
|
|
}
|
|
}
|