enhance: remove indoc, just use consts
This commit is contained in:
parent
bf02adeb33
commit
1912f0baf6
4 changed files with 22 additions and 35 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -160,12 +160,6 @@ version = "0.13.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edcd27d72f2f071c64249075f42e205ff93c9a4c5f6c6da53e79ed9f9832c285"
|
||||
|
||||
[[package]]
|
||||
name = "indoc"
|
||||
version = "2.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
|
||||
|
||||
[[package]]
|
||||
name = "kurbo"
|
||||
version = "0.11.1"
|
||||
|
@ -198,7 +192,6 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
|||
name = "luciders"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"indoc",
|
||||
"resvg",
|
||||
]
|
||||
|
||||
|
|
|
@ -5,5 +5,4 @@ edition = "2021"
|
|||
license = "AGPL-3.0-only"
|
||||
|
||||
[dependencies]
|
||||
indoc = "2.0.5"
|
||||
resvg = "0.44.0"
|
||||
|
|
20
src/constants.rs
Normal file
20
src/constants.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
pub const SERVER_INFO: &'static str = r#"luciders - Lucide SVG icons server <https://lucide.dev/>
|
||||
|
||||
GET /info - Get server information
|
||||
GET /icons/[icon].svg - Get an icon in SVG format (equivalent to fetching them directly from Lucide)
|
||||
GET /icons/[icon].png - Get an icon rendered in PNG format
|
||||
Query parameters:
|
||||
-- note: Make sure to URL encode the query parameters: particularly special characters such as # (e.g. %23). The server only accepts a small subset of characters deemed necessary for the query parameters.
|
||||
-- note: You may choose to use either colour or color (Commonwealth or US spelling) in the query parameters. Both are accepted. Specifying both will result in undefined behaviour, so don't do that!
|
||||
scale - integer - Scale the icon (default: 1, min: 1, max: 100)
|
||||
padding - integer - Add padding (px) around the icon (default: 0, min: 0, max: 100)
|
||||
background - hex - Set the background color in hex WITHOUT the hashtag (e.g. FFFFFF) (default: transparent)
|
||||
stroke_colour - string - Set the stroke color for the SVG icon, any CSS color WITH the hashtag (default: currentColor)
|
||||
discord_compatibility - boolean - Set padding to 8px for Discord compatibility. Typically for use in embed author icons as these have a circle clip applied by Discord. Overrides padding if set. (default: false)
|
||||
cache_key - string - Technically this can have any name. The server does not interpret this at all. Useful for cache busting. (default: none)
|
||||
Example:
|
||||
/icons/apple.png?scale=2&background=FF0000&discord_compatibility
|
||||
|
||||
|
||||
*** mantained with ❤️ by Compositr (Jim) ***
|
||||
"#;
|
29
src/main.rs
29
src/main.rs
|
@ -7,12 +7,11 @@ use resvg::{
|
|||
usvg,
|
||||
};
|
||||
|
||||
use indoc::indoc;
|
||||
|
||||
mod handlers;
|
||||
mod http;
|
||||
mod icons;
|
||||
mod threads;
|
||||
mod constants;
|
||||
|
||||
fn main() {
|
||||
println!("luciders starting...");
|
||||
|
@ -40,36 +39,12 @@ fn main() {
|
|||
Response::new(req, 200, Body::Static("OK - luciders is running"))
|
||||
});
|
||||
|
||||
const INFO: &str = indoc!(
|
||||
"
|
||||
luciders - Lucide SVG icons server <https://lucide.dev/>
|
||||
|
||||
GET /info - Get server information
|
||||
GET /icons/[icon].svg - Get an icon in SVG format (equivalent to fetching them directly from Lucide)
|
||||
GET /icons/[icon].png - Get an icon rendered in PNG format
|
||||
Query parameters:
|
||||
-- note: Make sure to URL encode the query parameters: particularly special characters such as # (e.g. %23). The server only accepts a small subset of characters deemed necessary for the query parameters.
|
||||
-- note: You may choose to use either colour or color (Commonwealth or US spelling) in the query parameters. Both are accepted. Specifying both will result in undefined behaviour, so don't do that!
|
||||
scale - integer - Scale the icon (default: 1, min: 1, max: 100)
|
||||
padding - integer - Add padding (px) around the icon (default: 0, min: 0, max: 100)
|
||||
background - hex - Set the background color in hex WITHOUT the hashtag (e.g. FFFFFF) (default: transparent)
|
||||
stroke_colour - string - Set the stroke color for the SVG icon, any CSS color WITH the hashtag (default: currentColor)
|
||||
discord_compatibility - boolean - Set padding to 8px for Discord compatibility. Typically for use in embed author icons as these have a circle clip applied by Discord. Overrides padding if set. (default: false)
|
||||
cache_key - string - Technically this can have any name. The server does not interpret this at all. Useful for cache busting. (default: none)
|
||||
Example:
|
||||
/icons/apple.png?scale=2&background=FF0000&discord_compatibility
|
||||
|
||||
|
||||
*** mantained with ❤️ by Compositr (Jim) ***
|
||||
"
|
||||
);
|
||||
|
||||
handlers.add_handler("/info", |req| {
|
||||
if req.method != "GET" {
|
||||
return Response::new(req, 405, Body::Static("Method Not Allowed"));
|
||||
}
|
||||
|
||||
Response::new(req, 200, Body::Static(INFO))
|
||||
Response::new(req, 200, Body::Static(constants::SERVER_INFO))
|
||||
});
|
||||
|
||||
handlers.add_handler("/icons/[icon].svg", {
|
||||
|
|
Loading…
Reference in a new issue