When you need to pretend you are a REST API, but you're really not
Vostok is a Rust-Based HTTP Transformation Layer To Seamlessly Convert REST Calls Into GraphQL Calls For Piecemeal API Migrations.
Need to implement some test servers for REST and for GraphQL. Need a Couple of Cases:
- Passthrough paths that are not overridden
- A direct transformation from REST<->GraphQL
- An advanced transformation from REST<->GraphQL which processes the data
We can set up a couple of REST endpoints:
GET /api/v1/uuid
returns a UUIDGET /api/v1/me
returns a JSON object{ data: { username: "Ariel", ... } }
And a GraphQL schema:
type User {
username: String!
}
Query {
me: User!
uuid: String!
}
TODO: Make the above setup a bit more advanced.
- hyper for managing HTTP requests
- routerify to manage routes in hyper
- anyhow for nice error handling
- log and fern for logging
- chrono for time handling
- hyper-rustls for handling HTTPS in hyper
- httpbin: A simple HTTP Request & Response Service. is very useful for testing
- cargo-watch for developing with
cargo dev
(install viacargo install cargo-watch
)
Potentially:
- warp as a higher-level alternative to hyper
- warp-reverse-proxy is a warp filter for easy reverse proxying
- reqwest is a high-level HTTP client
Some blog posts: