🏗️ Elegant & Highly Performant Async Gemini Server Framework for the Modern Age
async framework gemini-protocol protocol gemini rust
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(response): success with mime response

Fuwn 4ae6f12b 615ad823

+26 -7
+1 -1
Cargo.toml
··· 2 2 3 3 [package] 4 4 name = "windmark" 5 - version = "0.1.18" 5 + version = "0.1.19" 6 6 authors = ["Fuwn <contact@fuwn.me>"] 7 7 edition = "2021" 8 8 description = "An elegant and highly performant async Gemini server framework"
+3 -3
README.md
··· 15 15 # Cargo.toml 16 16 17 17 [dependencies] 18 - windmark = "0.1.18" 18 + windmark = "0.1.19" 19 19 tokio = { version = "0.2.4", features = ["full"] } 20 20 21 21 # If you would like to use the built-in logger (recommended) 22 - # windmark = { version = "0.1.18", features = ["logger"] } 22 + # windmark = { version = "0.1.19", features = ["logger"] } 23 23 24 24 # If you would like to use the built-in MIME dedection when `Success`-ing a file 25 25 # (recommended) 26 - # windmark = { version = "0.1.18", features = ["auto-deduce-mime"] } 26 + # windmark = { version = "0.1.19", features = ["auto-deduce-mime"] } 27 27 ``` 28 28 29 29 ### Implement a Windmark server
+6
examples/windmark.rs
··· 103 103 }), 104 104 ); 105 105 router.mount( 106 + "/specific-mime", 107 + Box::new(|_| { 108 + Response::SuccessWithMime("hi".to_string(), "text/plain".to_string()) 109 + }), 110 + ); 111 + router.mount( 106 112 "/ip", 107 113 Box::new(|context| { 108 114 Response::Success(
+9
src/response.rs
··· 23 23 Input(String), 24 24 SensitiveInput(String), 25 25 Success(String), 26 + /// A successful response where the MIME type of the response is manually 27 + /// specific by the user 28 + SuccessWithMime(String, String), 26 29 #[cfg(feature = "auto-deduce-mime")] 27 30 /// A successful response where the MIME type of the response is 28 31 /// automatically deduced from the provided bytes ··· 63 66 } 64 67 Response::Success(value) => { 65 68 *status = 20; 69 + 70 + value 71 + } 72 + Response::SuccessWithMime(value, value_mime) => { 73 + *status = 23; 74 + *mime = value_mime; 66 75 67 76 value 68 77 }
+7 -3
src/router.rs
··· 384 384 .write_all( 385 385 format!( 386 386 "{}{}\r\n{}", 387 - if response_status == 21 || response_status == 22 { 387 + if response_status == 21 388 + || response_status == 22 389 + || response_status == 23 390 + { 388 391 20 389 392 } else { 390 393 response_status ··· 395 398 " text/gemini; charset={}; lang={}", 396 399 self.charset, self.language 397 400 ), 401 + 21 => response_mime_type, 398 402 #[cfg(feature = "auto-deduce-mime")] 399 403 22 => format!(" {}", tree_magic::from_u8(&*content.as_bytes())), 400 - 21 => response_mime_type, 404 + 23 => response_mime_type, 401 405 _ => format!(" {}", content), 402 406 }, 403 407 match response_status { 404 408 20 => format!("{}{}\n{}", header, content, footer), 405 - 21 | 22 => content.to_string(), 409 + 21 | 22 | 23 => content.to_string(), 406 410 _ => "".to_string(), 407 411 } 408 412 )