baiji
Advanced tools
Comparing version 0.8.21 to 0.8.22
@@ -113,2 +113,7 @@ 'use strict'; | ||
// Alias `done()` | ||
respond() { | ||
return this.done.apply(this, arguments); | ||
} | ||
// General send response method, should be overwritten | ||
@@ -115,0 +120,0 @@ done() { |
@@ -98,4 +98,11 @@ 'use strict'; | ||
let contentType = ctx.get('Content-Type'); | ||
// Allow user specified content-type | ||
let contentType = ctx.response.get('Content-Type'); | ||
let hasAccept = ctx.get('Accept'); | ||
// If client do not send Accept header, then use user defined content-type | ||
if (!hasAccept && contentType) { | ||
accepts = contentType.toLowerCase(); | ||
} | ||
if (dataExists) { | ||
@@ -139,8 +146,12 @@ switch (accepts) { | ||
default: | ||
// not acceptable | ||
ctx.sendStatus(406); | ||
if (accepts) { | ||
ctx.send(data); | ||
} else { | ||
// not acceptable | ||
ctx.sendStatus(406); | ||
} | ||
break; | ||
} | ||
} else { | ||
if (!ctx.get('Content-Type')) { | ||
if (!contentType) { | ||
ctx.header('Content-Type', 'application/json'); | ||
@@ -194,3 +205,2 @@ } | ||
.method('format') | ||
.method('get') | ||
.method('json') | ||
@@ -220,2 +230,3 @@ .method('jsonp') | ||
.method('is') | ||
.method('get') | ||
.method('range') | ||
@@ -236,3 +247,2 @@ | ||
.getter('hostname') | ||
.getter('header') | ||
.getter('headers') | ||
@@ -239,0 +249,0 @@ .getter('ip') |
{ | ||
"name": "baiji", | ||
"version": "0.8.21", | ||
"version": "0.8.22", | ||
"description": "Baiji is an easy to use and opinionated micro-framework for writing scalable and REST-like web APIs. Its main goals are parameter validation, entities, hooks, scalability and allowing rapid development and deployment of such APIs.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
127328
3347