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
25 changes: 16 additions & 9 deletions actions/rest-action/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

#[hercules_sdk::runtime_event(
identifier = "REST",
signature = "<A extends REST_AUTH_TYPE, T extends TYPE>(http_schema: HTTP_SCHEMA, http_url: HTTP_URL, http_method: HTTP_METHOD, http_auth: A, http_auth_value: REST_AUTH_VALUE<A>, input_schema: T): REST_ADAPTER_INPUT<T>",
// Only the URL and the method are genuinely required: a bodyless
// request (`GET`, `DELETE`, `HEAD`) has no content type and no body to
// describe, so `http_schema` and `input_schema` have to be optional here
// too, not just on their `#[setting]`s — otherwise the signature demands
// values the request can never carry, and `T` collapses to `undefined`
// (`REST_ADAPTER_INPUT<undefined>.payload`) when no input schema is set.
signature = "<A extends REST_AUTH_TYPE, T extends TYPE>(http_url: HTTP_URL, http_method: HTTP_METHOD, http_schema?: HTTP_SCHEMA, http_auth?: A, http_auth_value?: REST_AUTH_VALUE<A>, input_schema?: T): REST_ADAPTER_INPUT<T>",
name(en_US = "Webhook"),
description(
en_US = "A Webhook is an HTTP endpoint that listens for incoming requests from external services or clients, allowing you to react to events in real time using standard HTTP methods like GET, POST, PUT, and DELETE."
Expand All @@ -22,14 +28,6 @@
linked_data_type_identifiers("REST_ADAPTER_INPUT"),
editable
)]
#[setting(
identifier = "http_schema",
name(en_US = "Content Type"),
description(
en_US = "Specifies the MIME type of the incoming request payload, such as application/json, application/xml, or text/plain. This determines the expected format of the payload parameter."
),
linked_data_type_identifiers("HTTP_SCHEMA")
)]
#[setting(
identifier = "http_url",
unique = "project",
Expand All @@ -43,6 +41,15 @@
description(en_US = "Specifies the HTTP request method (e.g., GET, POST, PUT, DELETE)."),
linked_data_type_identifiers("HTTP_METHOD")
)]
#[setting(
identifier = "http_schema",
name(en_US = "Content Type"),
description(
en_US = "Specifies the MIME type of the incoming request payload, such as application/json, application/xml, or text/plain. This determines the expected format of the payload parameter."
),
linked_data_type_identifiers("HTTP_SCHEMA"),
optional
)]
#[setting(
identifier = "http_auth",
name(en_US = "Authentication type"),
Expand Down
3 changes: 2 additions & 1 deletion actions/rest-action/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ use crate::pending::{self, PendingResponses, RespondPayload, RespondSignal};

#[hercules_sdk::runtime_function(
identifier = "rest::control::respond",
signature = "<S extends HTTP_SCHEMA>(http_status_code: HTTP_STATUS_CODE, http_schema: S, payload: HTTP_PAYLOAD<S>, headers?: OBJECT<{}>): void",
signature = "<S extends HTTP_SCHEMA>(http_status_code: HTTP_STATUS_CODE, http_schema: S, payload: HTTP_PAYLOAD<S>, headers?: OBJECT<{ [key: string]: string }>): void",
name(en_US = "Respond"),
description(
en_US = "Processes an HTTP response and returns it to the requesting client. This function typically completes the HTTP request–response cycle by delivering the server’s final output, such as headers, status codes, and body content, back to the client."
),
design = "end",
display_message(
en_US = "Sends response with status ${http_status_code} and payload ${payload}"
),
Expand Down
Loading