Client: Add new QueryRaw function#249
Merged
Merged
Conversation
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
This allows both the internal client code and externals that use the raw methods to parse the response from the API. Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Allow sending a query and getting the raw response. Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
QueryRaw function
masnax
suggested changes
Sep 9, 2024
| return c.QueryStruct(queryCtx, method, prefix, path, in, &out) | ||
| } | ||
|
|
||
| // QueryRaw is a helper for initiating a request on any endpoints defined external to microcluster. This function should be used for all client |
Contributor
There was a problem hiding this comment.
Maybe remove This function should be used for all client methods defined externally from microcluster here since it's more of a special case
Contributor
Author
There was a problem hiding this comment.
Thanks for bringing this up.
Had the same thought as you but left it in to clearly indicate that you should not use the internal QueryStruct/QueryStructRaw methods.
But probably at some time we will anyway revoke access to those so we can already start thinking this way. Removed :)
Allow sending a query and getting the raw response. Externals can use the response.ParseResponse func to both access the raw response but still parse it as usual. Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
e7321b3 to
883da01
Compare
masnax
approved these changes
Sep 9, 2024
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds another
QueryRawfunction to the client which allows accessing the raw*http.Response.That is required for the canonical/microcloud#383 in order to access the remotes certificate used in the TLS connection.
Furthermore the parsing of API responses is moved into the public facing package to allow any user of
QueryRawto both access the raw response and parsing it as usual.