Skip to content

Commit

Permalink
Feature/#1615 content headers (#240)
Browse files Browse the repository at this point in the history
* added support for resource versions

* updated dependencies

Co-authored-by: Valentin <valentin.genev@modusbox.com>
  • Loading branch information
vgenev and Valentin authored Sep 9, 2020
1 parent 4db9a82 commit 7021d02
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 30 deletions.
57 changes: 31 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "quoting-service",
"description": "Quoting Service hosted by a scheme",
"license": "Apache-2.0",
"version": "11.0.3",
"version": "11.1.0",
"author": "ModusBox",
"contributors": [
"James Bush <james.bush@modusbox.com>",
Expand Down Expand Up @@ -62,7 +62,7 @@
"@hapi/hapi": "20.0.0",
"@mojaloop/central-services-error-handling": "10.6.0",
"@mojaloop/central-services-logger": "10.6.0",
"@mojaloop/central-services-shared": "11.3.2",
"@mojaloop/central-services-shared": "11.3.3",
"@mojaloop/event-sdk": "10.6.0",
"@mojaloop/ml-number": "8.2.0",
"@mojaloop/sdk-standard-components": "10.3.2",
Expand All @@ -86,7 +86,7 @@
"jest": "26.4.2",
"jest-junit": "11.1.0",
"npm-audit-resolver": "2.2.1",
"npm-check-updates": "8.1.0",
"npm-check-updates": "8.1.1",
"nyc": "15.1.0",
"pre-commit": "1.2.2",
"proxyquire": "2.1.3",
Expand Down
7 changes: 6 additions & 1 deletion src/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const util = require('util')
const crypto = require('crypto')
const Enum = require('@mojaloop/central-services-shared').Enum
const Logger = require('@mojaloop/central-services-logger')
const resourceVersions = require('@mojaloop/central-services-shared').Util.resourceVersions

const failActionHandler = async (request, h, err) => {
Logger.error(`validation failure: ${getStackOrInspect}`)
Expand Down Expand Up @@ -125,8 +126,12 @@ function removeEmptyKeys (originalObject) {
* @returns {object}
*/
function generateRequestHeaders (headers, noAccept) {
let contentTypeHeader = headers['content-type'] || headers['Content-Type']
if (Enum.Http.Headers.GENERAL.CONTENT_TYPE.regex.test(contentTypeHeader) && !!resourceVersions.quotes.contentVersion) {
contentTypeHeader = `application/vnd.interoperability.quotes+json;version=${resourceVersions.quotes.contentVersion}`
}
const ret = {
'Content-Type': headers['content-type'] || headers['Content-Type'],
'Content-Type': contentTypeHeader,
Date: headers.date,
'FSPIOP-Source': headers['fspiop-source'],
'FSPIOP-Destination': headers['fspiop-destination'],
Expand Down

0 comments on commit 7021d02

Please sign in to comment.