-
Notifications
You must be signed in to change notification settings - Fork 0
PR: gh #66 : Changes for GET Request support in ut-control #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ae7c188
Add gh #66 : Adding first level changes for GET Request support in ut…
kanjoe24 f62d964
Add gh #66 : Added function in KVP to retreive data based on type
kanjoe24 6bd937b
Fix gh66 : Fix review comments
kanjoe24 a846b89
Fix gh# 66 : Fixing further review comments
kanjoe24 d710c52
Fix gh66 : Fix the naming conventions and further review comments
kanjoe24 5fedbd3
Add gh66 : Adding additional callback register function for handling …
kanjoe24 0db710e
Update gh66 : Updated as per review comments
kanjoe24 6688fa3
Add gh66 : Adding changes for handling GET requests with query params
kanjoe24 1f31e44
Rename gh #66 : Renaming the test scripts
kanjoe24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,9 +47,27 @@ typedef struct | |
|
|
||
| typedef void ut_controlPlane_instance_t; /*!< Handle to a control plane instance */ | ||
|
|
||
| /**** NOTE: This function will be deprecated in future major release ****/ | ||
| /** @brief Callback function type for handling control plane messages. */ | ||
| typedef void (*ut_control_callback_t)( char *key, ut_kvp_instance_t *instance, void *userData ); | ||
|
|
||
| /** | ||
| * @brief Callback function for handling HTTP requests to a specific REST API endpoint. | ||
| * | ||
| * This callback is invoked by the UT control server when an HTTP request (GET, POST, PUT, DELETE, etc.) | ||
| * is received and the requested REST API endpoint matches the `restAPI` parameter. | ||
| * | ||
| * @param restAPI The name of the REST API endpoint being called. | ||
| * @param httpRequestType The HTTP method of the request (e.g., "GET", "POST", "PUT", "DELETE"). | ||
| * @param userData User-defined data passed during registration of the callback. This can be used to | ||
| * pass context or state to the callback function. | ||
| * @param pData Pointer to the key-value pair (KVP) instance containing the data sent with the request. | ||
| * | ||
| * @return A dynamically allocated character string containing the JSON response from the API endpoint. | ||
| * The caller is responsible for freeing the returned string using `free()`. Returns `NULL` on error. | ||
| */ | ||
| typedef char *(*ut_control_endpoint_callback_t)(const char *restAPI, const char *httpRequestType, ut_kvp_instance_t *pData, void *userData); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extensed the callback, so support bool return for error / no error , with char *pReturnedString, uint32_t *pReturnedSize *pReturnedString - dynamically allocated character string containing the JSON response from the API endpoint. |
||
|
|
||
| /** | ||
| * @brief Initializes a control plane instance. | ||
| * @param monitorPort - Port number to monitor for incoming messages. | ||
|
|
@@ -58,6 +76,7 @@ typedef void (*ut_control_callback_t)( char *key, ut_kvp_instance_t *instance, v | |
| ut_controlPlane_instance_t* UT_ControlPlane_Init( uint32_t monitorPort ); | ||
|
|
||
| /** | ||
| * **** NOTE: This function will be deprecated in future major release **** | ||
| * @brief Registers a callback function for a specific message key. | ||
| * @param pInstance - Handle to the control plane instance. | ||
| * @param key - Null-terminated string representing the message key to trigger the callback. | ||
|
|
@@ -74,6 +93,39 @@ ut_control_plane_status_t UT_ControlPlane_RegisterCallbackOnMessage(ut_controlPl | |
| ut_control_callback_t callbackFunction, | ||
| void *userData); | ||
|
|
||
| /** | ||
| * @brief Registers a callback for a REST API endpoint (GET) or POST message key. | ||
| * | ||
| * Registers a callback function to be invoked when a GET request is made to the | ||
| * specified `restAPI` endpoint, or when a POST request is received with | ||
| * `restAPI` as the message key. | ||
| * | ||
| * @param[in] pInstance Pointer to the control plane instance. | ||
| * @param[in] httpRequestType The HTTP request type ("GET" or "POST"). | ||
| * @param[in] restAPI The REST API endpoint for GET requests, or the message key | ||
| * for POST requests. For example, "/users" for a GET | ||
| * request, or "status" for a POST request. | ||
| * @param[in] callbackFunction Pointer to the callback function. The function | ||
| * type depends on the request type: | ||
| * `ut_control_endpoint_callback_t` for GET requests, | ||
| * or `ut_control_on_message_callback_t` for POST | ||
| * requests. | ||
| * @param[in] userData Pointer to user-provided data that will be passed to the | ||
| * callback function. This can be used, for example, to | ||
| * pass a pointer to context data. | ||
| * @returns A status code indicating the result of the operation. | ||
| * @retval UT_CONTROL_PLANE_STATUS_OK Success. | ||
| * @retval UT_CONTROL_PLANE_STATUS_INVALID_HANDLE Invalid `pInstance`. | ||
| * @retval UT_CONTROL_PLANE_STATUS_INVALID_PARAM Invalid `restAPI` or | ||
| * `callbackFunction`. | ||
| * @retval UT_CONTROL_PLANE_STATUS_CALLBACK_LIST_FULL Callback list is full. | ||
| */ | ||
| ut_control_plane_status_t UT_ControlPlane_RegisterEndPointCallback( | ||
kanjoe24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ut_controlPlane_instance_t *pInstance, | ||
| const char *httpRequestType, | ||
| char *restAPI, ut_control_endpoint_callback_t callbackFunction, | ||
| void *userData); | ||
|
|
||
| /** | ||
| * @brief Starts the control plane listening for incoming messages. | ||
| * @param pInstance - Handle to the control plane instance. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.