Skip to content

Conversation

oguzkocer
Copy link
Contributor

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 in wp_networking crate for types in the wp_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 the WPNetworkRequest from wp_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 a test_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}:

https://foo.bar
{authentication_token}

@oguzkocer oguzkocer merged commit 8720db9 into trunk Dec 13, 2023
@oguzkocer oguzkocer deleted the simple-request branch December 13, 2023 22:05
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