Flaska: Add basic head support
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded

This commit is contained in:
Jonatan Nilsson 2022-03-21 07:34:01 +00:00
parent 28b4f6ea33
commit e50e9f8a94
2 changed files with 12 additions and 0 deletions

View file

@ -487,6 +487,9 @@ export class Flaska {
'OPTIONS': new FlaskaRouter(),
'PATCH': new FlaskaRouter(),
}
// HEAD and GET should be identical
this.routers['HEAD'] = this.routers['GET']
this.get = this.routers.GET.addRoute.bind(this.routers.GET)
this.post = this.routers.POST.addRoute.bind(this.routers.POST)
this.put = this.routers.PUT.addRoute.bind(this.routers.PUT)

View file

@ -25,6 +25,15 @@ t.test('it should have all the common verbs', function() {
assert.strictEqual(typeof(flaska.patch), 'function')
})
t.test('the verbs GET and HEAD should be identical', function() {
let flaska = new Flaska({}, faker)
assert.ok(flaska.get)
assert.strictEqual(typeof(flaska.get), 'function')
assert.notOk(flaska.head)
assert.ok(flaska.routers['HEAD'])
assert.strictEqual(flaska.routers['GET'], flaska.routers['HEAD'])
})
t.describe('#log', function() {
t.test('default have a logger valid', function() {
let flaska = new Flaska({}, faker)