+ hudozka-middlewares, + hudozka-api-v1
This commit is contained in:
1 parent
6347e4db35
commit
35cc7c0caa
17 files changed
+175
-61
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import {parse} from 'ejson';
|
||||
|
||||
export function ejson(type='application/ejson') {
|
||||
return async (ctx, next) => {
|
||||
let t = ctx.request.headers['content-type'];
|
||||
let data = ctx.request.body;
|
||||
|
||||
if (t === type){
|
||||
data = typeof data === 'string' ? data : JSON.stringify(data);
|
||||
ctx.request.body = parse(data);
|
||||
}
|
||||
|
||||
await next();
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user