Add ability to make simple requests and parse them for a functional prototype #4
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 connects the dots in the current implementation to be able to make simple requests and parse them for a functional prototype. A lot of how that's implemented is through temporary means as the design for several of the components are not fully fleshed out yet. So, the implementation has a lot of TODOs to get this to a more production ready state.
Considering that this project as a whole is in its prototype stage, we need parts of it to be throwaway code to get it to a stage where we can test things out. Scaffolding can only do so much for us and we needed something like this to test its integration with native layers.
There is a good chance this prototype will become a proper project and that's why I wanted to leave a lot of TODOs so we don't end up using throwaway code in production. I think I'll get to address some of these TODOs before this goes out of prototype stage, but some of it I intend to keep, because it's just not worth polishing it until we address the more important parts.
As for the implementation, I found the design we landed on to be pleasant to work in. I found some parts to be a little bit annoying - such as not being able to implement
From
trait inwp_networking
crate for types in thewp_api
crate. However, the frustrations were generally minor and always had straightforward replacements.I really like how simple we can keep
WPNetworking
implementation and how it can be easily replaced without knowing any details about the requests. I also like that the authentication headers can be built into theWPNetworkRequest
fromwp_networking
crate and not require those details to be directly exposed to a custom networking layer.I am not quite sure about error handling. I have a decent understanding of the possibilities in Rust ecosystem (although it can be a bit of a hard topic to get right even in pure Rust crates) and uniffi bindings. However, I don't have a clear picture of how exactly we'll structure our errors and what will be exposed in each layer. I don't think this is a problem that we'll be able to figure as part of this prototype. So, we might do a throwaway implementation just to test how it could possibly integrate into native layers.
If you'd like to test this using the
wp_cli
, you need to add atest_credentials
file at the root of the project where the first line is the site url and second line is the base 64 encoded authentication token of{username}:{application_password}
: