Skip to content

Registered functions return String instead of int#279

Open
areyalp wants to merge 1 commit intomarcoschwartz:masterfrom
areyalp:master
Open

Registered functions return String instead of int#279
areyalp wants to merge 1 commit intomarcoschwartz:masterfrom
areyalp:master

Conversation

@areyalp
Copy link
Copy Markdown

@areyalp areyalp commented Apr 12, 2020

Now registered function methods in the code return String instead of int. For instance, it would allow the responses to be more complex, now it can be returned a response containing String, int casted to String or even a JSON or XML. Therefore, it lets you reply with more than one simple integer.

E.g:

void setup() {
.
.
.
rest.function("test", testFunction);
}

String testFunction(String params) {
String strJson= "{\"key1\" : \"value1\", \"key2\" : \"value2\"}";
return strJson;
}

I did a test with the following result:

image

Now registered function methods in the code return String instead of int. For instance, it would allow the responses to be more complex, now it can be returned a response containing String, int casted to String or even a JSON or XML. Therefore, it lets you reply with more than one simple integer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant