Add support for path parameters
This commit is contained in:
parent
0bfa0d91b4
commit
d476478192
3 changed files with 29 additions and 4 deletions
|
@ -17,7 +17,7 @@ class ContextExecutor {
|
|||
this.mocks = new CopyOnWriteArrayList<>([initialMock])
|
||||
httpServerWraper.createContext(path, {
|
||||
HttpExchange ex ->
|
||||
MockRequest request = new MockRequest(ex.requestBody.text, ex.requestHeaders, ex.requestURI.query)
|
||||
MockRequest request = new MockRequest(ex.requestBody.text, ex.requestHeaders, ex.requestURI)
|
||||
println "Mock received input"
|
||||
for (Mock mock : mocks) {
|
||||
try {
|
||||
|
|
|
@ -13,14 +13,16 @@ class MockRequest {
|
|||
final GPathResult xml
|
||||
final GPathResult soap
|
||||
final Object json
|
||||
final List<String> path
|
||||
|
||||
MockRequest(String text, Headers headers, String query) {
|
||||
MockRequest(String text, Headers headers, URI uri) {
|
||||
this.text = text
|
||||
this.headers = headersToMap(headers)
|
||||
this.query = queryParamsToMap(query)
|
||||
this.query = queryParamsToMap(uri.query)
|
||||
this.xml = inputToXml(text)
|
||||
this.soap = inputToSoap(xml)
|
||||
this.json = inputToJson(text)
|
||||
this.path = uri.path.split('/').findAll()
|
||||
}
|
||||
|
||||
private static GPathResult inputToXml(String text) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue