Skip to content

Commit

Permalink
fix(HyperRequest): Correctly set the encodeUrl when cloning a request
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Dec 1, 2022
1 parent 7a80b01 commit c996b0f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -898,27 +898,21 @@ component {
.initWith(
baseUrl = "https://swapi.co/api"
);
}

function afterAspectsLoad(){
// Map Bindings below
map( "GitHubClient" )

map( "GitHubClient" )
.to( "hyper.models.HyperBuilder" )
.asSingleton()
.initWith(
baseUrl = "https://api.github.com",
headers = {
"Content-Type" : "application/json", // If you map to a builder with headers - make sure you set your Content-Type if desired
"Authorization" = getColdBox().getSetting( "SWAPI_TOKEN" )
"Authorization" = getColdBox().getUtil().getSystemSetting( "SWAPI_TOKEN" )
}
);
}
}

}
```

Note: If you are mapping a builder and use the `initWith( headers = {... } )`, these headers will overwrite the default headers you get with a HyperRequest so you might see some inconsistencies. A hyperRequest defaults the headers to `"Content-Type" : "application/json"`, so if you want to set a content-type, please include that in your headers struct, like above.

You can also set or change the defaults by either passing the key / value pairs in to the `init` method or by calling the appropriate `HyperRequest` method on the `HyperBuilder.defaults` property.

```js
Expand Down Expand Up @@ -1065,4 +1059,4 @@ Hyper announces two interception points you can listen to in your ColdBox applic

`onHyperRequest` receives a struct with a `request` key as the data.

`onHyperResponse` receives a struct with a `response` key as the data.
`onHyperResponse` receives a struct with a `response` key as the data.
1 change: 1 addition & 0 deletions models/HyperRequest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ component accessors="true" {
req.setBaseUrl( variables.baseUrl );
req.setUrl( variables.url );
req.setResolveUrls( variables.resolveUrls );
req.setEncodeUrl( variables.encodeUrl );
req.setMethod( variables.method );
req.setUsername( variables.username );
req.setPassword( variables.password );
Expand Down
4 changes: 3 additions & 1 deletion tests/resources/ModuleIntegrationSpec.cfc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
component extends="coldbox.system.testing.BaseTestCase" {

this.unloadColdBox = false;

function beforeAll() {
super.beforeAll();

getController().getModuleService()
.registerAndActivateModule( "hyper", "testingModuleRoot" );
}
Expand Down

0 comments on commit c996b0f

Please sign in to comment.