Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,16 @@ protected CallHttpTaskBuilder() {
public CallHttpTaskBuilder self() {
return this;
}

/**
* Sets the output expression for this task (equivalent to {@code output.as} in YAML).
*
* <p>Uses jq expression syntax (e.g., {@code $.field} to select a field from the result).
*
* @param expr jq expression to extract the desired output value from the task result
* @return this builder for chaining
*/
public CallHttpTaskBuilder outputAs(String expr) {
return this.output(b -> b.as(expr));
}
Comment thread
matheusandre1 marked this conversation as resolved.
Comment thread
matheusandre1 marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,26 @@ public interface BaseCallHttpSpec<SELF extends BaseCallHttpSpec<SELF>> {
*/
List<Consumer<CallHttpTaskFluent<?>>> steps();

default SELF GET() {
default SELF get() {
steps().add(c -> c.method("GET"));
return self();
}

default SELF POST() {
@Deprecated
default SELF GET() {
return get();
}

default SELF post() {
steps().add(c -> c.method("POST"));
return self();
}

@Deprecated
default SELF POST() {
return post();
}

default SELF acceptJSON() {
return header("Accept", "application/json");
}
Expand Down Expand Up @@ -122,6 +132,59 @@ default SELF query(String name, String value) {
return self();
}

default SELF put() {
steps().add(c -> c.method("PUT"));
return self();
}

default SELF delete() {
steps().add(c -> c.method("DELETE"));
return self();
}

default SELF patch() {
steps().add(c -> c.method("PATCH"));
return self();
}

default SELF head() {
steps().add(c -> c.method("HEAD"));
return self();
}

default SELF options() {
steps().add(c -> c.method("OPTIONS"));
return self();
}

default SELF acceptXML() {
return header("Accept", "application/xml");
}

default SELF acceptForm() {
return header("Accept", "application/x-www-form-urlencoded");
}

default SELF acceptText() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put an acceptJson?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put an acceptJson?

default SELF acceptJSON() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, really I did not see it.

return header("Accept", "text/plain");
}

default SELF contentTypeJSON() {
return header("Content-Type", "application/json");
}

default SELF contentTypeXML() {
return header("Content-Type", "application/xml");
}

default SELF contentTypeForm() {
return header("Content-Type", "application/x-www-form-urlencoded");
}

default SELF contentTypeText() {
return header("Content-Type", "text/plain");
}

default SELF redirect(boolean redirect) {
steps().add(c -> c.redirect(redirect));
return self();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.serverlessworkflow.fluent.spec.spi.CallHttpTaskFluent;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;

public final class CallHttpSpec implements BaseCallHttpSpec<CallHttpSpec>, CallHttpConfigurer {
Expand All @@ -42,4 +43,19 @@ public List<Consumer<CallHttpTaskFluent<?>>> steps() {
public void accept(CallHttpTaskBuilder builder) {
BaseCallHttpSpec.super.accept(builder);
}

@Override
public CallHttpSpec andThen(Consumer<? super CallHttpTaskBuilder> after) {
Objects.requireNonNull(after, "after");
steps.add(
fluent -> {
if (!(fluent instanceof CallHttpTaskBuilder builder)) {
throw new IllegalArgumentException(
"andThen requires CallHttpTaskBuilder, got: "
+ (fluent == null ? "null" : fluent.getClass().getName()));
}
after.accept(builder);
});
return this;
}
Comment thread
matheusandre1 marked this conversation as resolved.
Comment thread
fjtirado marked this conversation as resolved.
}
Loading
Loading