[#5] Minor enhancements
This commit is contained in:
@@ -18,15 +18,13 @@ class GroovyDsl {
|
||||
}
|
||||
|
||||
void request(@DelegatesTo(Request) Closure closure) {
|
||||
Request request = new Request()
|
||||
this.request = request
|
||||
this.request = new Request()
|
||||
closure.delegate = request
|
||||
closure()
|
||||
}
|
||||
|
||||
void response(@DelegatesTo(Response) Closure closure) {
|
||||
Response response = new Response()
|
||||
this.response = response
|
||||
this.response = new Response()
|
||||
closure.delegate = response
|
||||
closure()
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@ import groovy.transform.CompileStatic
|
||||
@CompileStatic
|
||||
class ClientDslProperty extends DslProperty {
|
||||
|
||||
ClientDslProperty(Object clientValue, Object serverValue) {
|
||||
super(clientValue, serverValue) }
|
||||
|
||||
ClientDslProperty(Object singleValue) {
|
||||
super(singleValue)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class Common {
|
||||
}
|
||||
|
||||
DslProperty $(ServerDslProperty server, ClientDslProperty client) {
|
||||
return value(client, server)
|
||||
return value(server, client)
|
||||
}
|
||||
|
||||
ClientDslProperty client(Object clientValue) {
|
||||
@@ -49,5 +49,4 @@ class Common {
|
||||
ServerDslProperty server(Object serverValue) {
|
||||
return new ServerDslProperty(serverValue)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package io.coderate.accurest.dsl.internal
|
||||
|
||||
//TODO: There is problem with a trait usage
|
||||
class DelegateHelper {
|
||||
|
||||
public static <T> void delegateToClosure(@DelegatesTo(T) Closure closure, T delegate) {
|
||||
closure.delegate = delegate
|
||||
closure()
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
package io.coderate.accurest.dsl.internal
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
|
||||
@CompileStatic
|
||||
|
||||
@@ -2,8 +2,6 @@ package io.coderate.accurest.dsl.internal
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.transform.TypeChecked
|
||||
|
||||
import static io.coderate.accurest.dsl.internal.DelegateHelper.delegateToClosure
|
||||
|
||||
@TypeChecked
|
||||
class Request extends Common {
|
||||
|
||||
@@ -49,9 +47,9 @@ class Request extends Common {
|
||||
}
|
||||
|
||||
void headers(@DelegatesTo(Headers) Closure closure) {
|
||||
Headers headers = new Headers()
|
||||
this.headers = headers
|
||||
delegateToClosure(closure, headers)
|
||||
this.headers = new Headers()
|
||||
closure.delegate = headers
|
||||
closure()
|
||||
}
|
||||
|
||||
void urlPath(String urlPath) {
|
||||
|
||||
@@ -3,8 +3,6 @@ package io.coderate.accurest.dsl.internal
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.transform.TypeChecked
|
||||
|
||||
import static io.coderate.accurest.dsl.internal.DelegateHelper.delegateToClosure
|
||||
|
||||
@TypeChecked
|
||||
class Response extends Common {
|
||||
|
||||
@@ -31,7 +29,8 @@ class Response extends Common {
|
||||
|
||||
void headers(@DelegatesTo(Headers) Closure closure) {
|
||||
this.headers = new Headers()
|
||||
delegateToClosure(closure, headers)
|
||||
closure.delegate = headers
|
||||
closure()
|
||||
}
|
||||
|
||||
void body(Map<String, Object> body) {
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package io.coderate.accurest.dsl.internal
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
|
||||
@CompileStatic
|
||||
class ServerDslProperty extends DslProperty {
|
||||
|
||||
ServerDslProperty(Object clientValue, Object serverValue) {
|
||||
super(clientValue, serverValue) }
|
||||
|
||||
ServerDslProperty(Object singleValue) {
|
||||
super(singleValue)
|
||||
}
|
||||
|
||||
@@ -94,6 +94,4 @@ class WithValuePattern {
|
||||
void matchesJsonPath(DslProperty matchesJsonPath) {
|
||||
this.matchesJsonPath = matchesJsonPath
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user