Improve response factories and add helper functions

This commit is contained in:
garrettmills
2020-07-29 22:55:17 -05:00
parent 0d4881de1f
commit 0764085ef9
9 changed files with 102 additions and 12 deletions

View File

@@ -1,13 +1,18 @@
import Controller from '../../../lib/src/http/Controller.ts'
import {Request} from '../../../lib/src/http/Request.ts'
import {error, html, redirect} from '../../../lib/src/http/response/helpers.ts'
export default class TestController extends Controller {
get_home(req: any) {
req.response.body = 'Hello!'
get_home(request: Request) {
return html('<h1>Hi!</h1>')
}
get_user_home(req: any) {
throw new Error('Hello, world!')
}
create_user_home(req: any) {}
get_user_home(request: Request) {
return redirect('/home')
}
create_user_home(request: Request) {
return error('Not implemented!')
}
}