Simple Rust webserver that exposes two REST-API endpoints:
- GET
/alive
for simple checking if the server is up - POST
/transform
which ingests a JSON payload such as:
{
"html":"<div><p>Hello World</p><span>Not a paragraph</span></div>",
"transform":"uppercase"
}
and returns the input HTML string transformed according to the specified transform method:
<div><p>HELLO WORLD</p><span>Not a paragraph</span></div>
For general usage, navigate to the page hosted below:
HTML Text Transformer (Please note as the backend is hosted via a free service it may need a minute or two of attempting requests to spin up, after which point requests will respond instantly)
The frontend is hosted via Github Pages, and the backend is hosted via Render.com
See below for local running instructions
All subsequent commands are run in the root of this repository and assume a default installation of Rust is present on the system.
cargo run --release -- --local
cargo build --release
./target/release/case-transformer-rs --local
cargo test
-
Run according to the instructions above
-
In a separate terminal:
curl -X POST http://localhost:5000/api/v1/transform -H "Content-Type: application/json" -d '{"html":"<div><p>Hello World</p><span>Not a paragraph</span></div>", "transform":"uppercase"}'
Expected results:
<div><p>HELLO WORLD</p><span>Not a paragraph</span></div>
- Dockerize the backend - To ensure ease of installation and running on any hosting service, dockerizing the backend would be a nice addition
- Write a proper frontend with something like the Leptos framework, compile it to WASM, serve it via the backend
- Implement rate limiting on the backend and other safety features
- Fully document the codebase
- Handle CORS with more granularity - currently allowing anything, but with a proper frontend in place I would want to only allow certain headers, origins and methods
- Add a results history, store it to an SQL database for viewing
- Add a login to associate users with their history