Skip to content

Commit

Permalink
Makes header name configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
richfab committed Jul 12, 2023
1 parent 3a4410e commit 453fff0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
3 changes: 2 additions & 1 deletion gbfs-validator/__test__/__snapshots__/gbfs.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ GBFS {
"auth": Object {
"apiKey": Object {
"key": "mykey",
"value": "myvalue",
},
"type": "api_key",
},
"gotOptions": Object {
"headers": Object {
"X-API-KEY": "mykey",
"mykey": "myvalue",
},
},
"options": Object {
Expand Down
5 changes: 4 additions & 1 deletion gbfs-validator/__test__/gbfs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ describe('initialization', () => {
new GBFS('http://localhost:8888/gbfs.json', {
auth: {
type: 'api_key',
apiKey: { key: 'mykey' }
apiKey: {
key: 'mykey',
value: 'myvalue'
}
}
})
).toMatchSnapshot()
Expand Down
2 changes: 1 addition & 1 deletion gbfs-validator/gbfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class GBFS {

if (this.auth.type === 'api_key' && this.auth.apiKey) {
this.gotOptions.headers = {
'X-API-KEY': `${this.auth.apiKey.key}`
[this.auth.apiKey.key]: `${this.auth.apiKey.value}`
}
}
}
Expand Down
23 changes: 17 additions & 6 deletions website/src/pages/Validator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,28 @@ function updateURL() {
></b-form-input>
</b-form-group>

<b-form-group
<b-form-group
id="input-group-api_key"
label="Authentification"
label-for="input-api_key"
v-if="state.options.auth.type === 'api_key'"
>
<b-form-input
id="input-api_key"
placeholder="key"
v-model="state.options.auth.apiKey.key"
></b-form-input>
<b-row>
<b-col>
<b-form-input
id="input-api_key-key"
placeholder="key"
v-model="state.options.auth.apiKey.key"
></b-form-input>
</b-col>
<b-col>
<b-form-input
id="input-api_key-value"
placeholder="value"
v-model="state.options.auth.apiKey.value"
></b-form-input>
</b-col>
</b-row>
</b-form-group>

<b-form-group
Expand Down

0 comments on commit 453fff0

Please sign in to comment.