1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Base Application
//!
//! All applications impl from [Application]. If a struct impls Application,
//! then all protocols will implicitly impl the struct. This makes it very easy
//! to make custom applications.
//!
//! ### Example
//!
//! If you wanted to create a single page application that ran on CGI, your
//! application might look something like this.
//!
//! ```no_run
//! use async_trait::async_trait;
//! use gemfra::{
//! application::Application,
//! error::AnyError,
//! request::Request,
//! response::Response,
//! protocol::Cgi,
//! };
//!
//! struct MyApp;
//!
//! #[async_trait]
//! impl Application for MyApp {
//! async fn handle_request(&self, request: Request) -> Result<Response, AnyError> {
//! Ok(Response::success("text/gemini", "# Hello World!
//!
//! Welcome to my simple app! This could have been just a simple gmi file, but I
//! guess it makes sense as an example :).
//! "))
//! }
//! }
//!
//! #[tokio::main]
//! async fn main() {
//! MyApp.run_cgi().await;
//! }
//! ```
//!
use async_trait;
use crate::;
/// Base Application
///
/// All applications impl from this trait. If a struct impls Application,
/// then all protocols will implicitly impl the struct. This makes it very easy
/// to make custom applications.