2020-07-22 14:38:17 +00:00
|
|
|
import Middleware from '../../../lib/src/http/Middleware.ts'
|
2020-09-04 15:46:08 +00:00
|
|
|
import {Request} from '../../../lib/src/http/Request.ts'
|
|
|
|
import {http} from '../../../lib/src/http/response/helpers.ts'
|
|
|
|
import {HTTPStatus} from '../../../lib/src/const/http.ts'
|
2020-07-22 14:38:17 +00:00
|
|
|
|
|
|
|
export default class TestMiddleware extends Middleware {
|
2020-09-04 15:46:08 +00:00
|
|
|
public async handleRequest(request: Request) {
|
|
|
|
if ( Math.random() >= 0.5 ) {
|
|
|
|
return http(HTTPStatus.FORBIDDEN, 'Well, you were unlucky.')
|
|
|
|
}
|
|
|
|
}
|
2020-07-22 14:38:17 +00:00
|
|
|
}
|