⚠️ This is an unofficial fork of the Rust service library for Merrymake.⚠️
It defines all the basic functions needed to work with Merrymake.
Add the following dependency to your Merrymake service:
merrymake-service-library = { git = "https://github.com/aekvi/rust-service-library.git", tag = "latest" }
Also, Merrymake requires the entry point app
. You can specify your src/main.rs
file as this entry point by adding the following to your Cargo.toml
:
[[bin]]
name = "app"
path = "src/main.rs"
Here is the most basic example of how to use this library:
use merrymake_service_library::{merrymake_service, reply_str_to_origin, Envelope};
use std::str;
pub fn main() -> Result<(), String> {
merrymake_service!(
{
actions: {
"handleHello": handle_hello
}
}
)
}
pub fn handle_hello(buffer: Vec<u8>, _envelope: Envelope) -> Result<(), String> {
let payload = str::from_utf8(&buffer).unwrap();
reply_str_to_origin(format!("Hello, {}!", payload).as_str()).unwrap();
Ok(())
}
For more information check out tutorials at merrymake.dev.
All templates are available through the CLI and on GitHub.