Crates.io | stocki |
lib.rs | stocki |
version | 0.1.0 |
source | src |
created_at | 2022-09-22 07:26:22.589053 |
updated_at | 2022-09-22 07:26:22.589053 |
description | Make tiny web services |
homepage | |
repository | https://github.com/JonnyOrman/stocki/ |
max_upload_size | |
id | 671512 |
size | 9,298 |
Make tiny, single feature web services.
Create a new project:
cargo new stocki-example
cd into it and install stocki
:
cd stocki-example
cargo install stocki
Replace the contents of src/main.rs
with this:
fn main() {
use stocki::{
run,
requests::{
Request,
HandleRequest
},
responses::{
Response
}
};
fn main() {
let handler = RequestHandler::new();
run(
"localhost:7878".to_string(),
"GET".to_string(),
handler);
}
pub struct RequestHandler{}
impl RequestHandler {
fn new() -> Self{Self{}}
}
impl HandleRequest for RequestHandler {
fn handle(&self, _request: Request) -> Response{
println!("stocki works!");
return Response::new(200);
}
}
Run the project:
cargo run
Make a GET
request to localhost:7878
. You should get a 200
response and see a "stocki works!" log message!