🏗️ 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.

fix(ci): fix tests and doc examples

Fuwn 875e201e 26a2b91f

+43 -26
+5
Makefile.toml
··· 16 16 command = "cargo" 17 17 toolchain = "nightly" 18 18 19 + [tasks.test] 20 + args = ["test", "--no-default-features", "--features", "logger,auto-deduce-mime,response-macros,${@}"] 21 + command = "cargo" 22 + toolchain = "1.68.2" 23 + 19 24 [tasks.checkf] 20 25 script = ''' 21 26 #!@shell
+2 -2
README.md
··· 44 44 .set_private_key_file("windmark_private.pem") 45 45 .set_certificate_file("windmark_public.pem") 46 46 .mount("/", windmark::success!("Hello, World!")) 47 - .set_error_handler( 48 - windmark::permanent_failure!("This route does not exist!") 47 + .set_error_handler(|_| 48 + windmark::Response::permanent_failure("This route does not exist!") 49 49 ) 50 50 .run() 51 51 .await
+3
examples/async.rs
··· 20 20 #[windmark::main] 21 21 async fn main() -> Result<(), Box<dyn std::error::Error>> { 22 22 let mut router = windmark::Router::new(); 23 + #[cfg(feature = "tokio")] 23 24 let async_clicks = std::sync::Arc::new(tokio::sync::Mutex::new(0)); 25 + #[cfg(feature = "async-std")] 26 + let async_clicks = std::sync::Arc::new(async_std::sync::Mutex::new(0)); 24 27 25 28 router.set_private_key_file("windmark_private.pem"); 26 29 router.set_certificate_file("windmark_public.pem");
+33 -24
src/router.rs
··· 200 200 /// 201 201 /// ```rust 202 202 /// windmark::Router::new().set_error_handler(|_| { 203 - /// windmark::success!("You have encountered an error!") 203 + /// windmark::Response::success("You have encountered an error!") 204 204 /// }); 205 205 /// ``` 206 206 pub fn set_error_handler<R>( ··· 227 227 /// # Examples 228 228 /// 229 229 /// ```rust 230 - /// windmark::Router::new().add_header(|context| { 231 - /// format!("This is displayed at the top of {}!", context.url.path()) 232 - /// }); 230 + /// windmark::Router::new().add_header( 231 + /// |context: windmark::context::RouteContext| { 232 + /// format!("This is displayed at the top of {}!", context.url.path()) 233 + /// }, 234 + /// ); 233 235 /// ``` 234 236 pub fn add_header(&mut self, handler: impl Partial + 'static) -> &mut Self { 235 237 (*self.headers.lock().unwrap()).push(Box::new(handler)); ··· 246 248 /// # Examples 247 249 /// 248 250 /// ```rust 249 - /// windmark::Router::new().add_footer(|context| { 250 - /// format!("This is displayed at the bottom of {}!", context.url.path()) 251 - /// }); 251 + /// windmark::Router::new().add_footer( 252 + /// |context: windmark::context::RouteContext| { 253 + /// format!("This is displayed at the bottom of {}!", context.url.path()) 254 + /// }, 255 + /// ); 252 256 /// ``` 253 257 pub fn add_footer(&mut self, handler: impl Partial + 'static) -> &mut Self { 254 258 (*self.footers.lock().unwrap()).push(Box::new(handler)); ··· 615 619 /// ```rust 616 620 /// use log::info; 617 621 /// 618 - /// windmark::Router::new().set_pre_route_callback(|context| { 619 - /// info!( 620 - /// "accepted connection from {}", 621 - /// context.stream.peer_addr().unwrap().ip(), 622 - /// ) 623 - /// }); 622 + /// windmark::Router::new().set_pre_route_callback( 623 + /// |context: windmark::context::HookContext| { 624 + /// info!( 625 + /// "accepted connection from {}", 626 + /// context.peer_address.unwrap().ip(), 627 + /// ) 628 + /// }, 629 + /// ); 624 630 /// ``` 625 631 pub fn set_pre_route_callback( 626 632 &mut self, ··· 638 644 /// ```rust 639 645 /// use log::info; 640 646 /// 641 - /// windmark::Router::new().set_post_route_callback(|context, _| { 642 - /// info!( 643 - /// "closed connection from {}", 644 - /// context.stream.peer_addr().unwrap().ip(), 645 - /// ) 646 - /// }); 647 + /// windmark::Router::new().set_post_route_callback( 648 + /// |context: windmark::context::HookContext, 649 + /// _content: &mut windmark::Response| { 650 + /// info!( 651 + /// "closed connection from {}", 652 + /// context.peer_address.unwrap().ip(), 653 + /// ) 654 + /// }, 655 + /// ); 647 656 /// ``` 648 657 pub fn set_post_route_callback( 649 658 &mut self, ··· 731 740 /// info!("clicker has been attached!"); 732 741 /// } 733 742 /// 734 - /// async fn on_pre_route(&mut self, context: HookContext<'_>) { 743 + /// async fn on_pre_route(&mut self, context: HookContext) { 735 744 /// self.clicks += 1; 736 745 /// 737 746 /// info!( ··· 741 750 /// ); 742 751 /// } 743 752 /// 744 - /// async fn on_post_route(&mut self, context: HookContext<'_>) { 753 + /// async fn on_post_route(&mut self, context: HookContext) { 745 754 /// info!( 746 755 /// "clicker has been called post-route on {} with {} clicks!", 747 756 /// context.url.path(), ··· 793 802 /// info!("clicker has been attached!"); 794 803 /// } 795 804 /// 796 - /// fn on_pre_route(&mut self, context: HookContext<'_>) { 805 + /// fn on_pre_route(&mut self, context: HookContext) { 797 806 /// self.clicks += 1; 798 807 /// 799 808 /// info!( ··· 803 812 /// ); 804 813 /// } 805 814 /// 806 - /// fn on_post_route(&mut self, context: HookContext<'_>) { 815 + /// fn on_post_route(&mut self, context: HookContext) { 807 816 /// info!( 808 817 /// "clicker has been called post-route on {} with {} clicks!", 809 818 /// context.url.path(), ··· 854 863 /// # Examples 855 864 /// 856 865 /// ```rust 857 - /// windmark::Router::new().set_languages("en"); 866 + /// windmark::Router::new().set_languages(["en"]); 858 867 /// ``` 859 868 pub fn set_languages<S>(&mut self, language: impl AsRef<[S]>) -> &mut Self 860 869 where S: Into<String> + AsRef<str> {