Skip to content

Commit

Permalink
Hook up documentation generation to dispatch.
Browse files Browse the repository at this point in the history
Closes #54
Closes #55
Closes #71
  • Loading branch information
jbearer committed Aug 18, 2022
1 parent 03433ae commit fae7016
Show file tree
Hide file tree
Showing 8 changed files with 350 additions and 394 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jf-utils = { features = ["std"], git = "https://github.com/EspressoSystems/jelly
lazy_static = "1.4.0"
libc = "0.2.126"
markdown = "0.3"
maud = { version = "0.23", features = ["tide"] }
parking_lot = "0.12.0"
routefinder = "0.5.0"
semver = "1.0"
Expand Down
8 changes: 8 additions & 0 deletions examples/hello-world/api.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
[meta]
NAME = "hello-world"
DESCRIPTION = "An example of a simple Tide Disco module"
FORMAT_VERSION = "0.1.0"

[route.greeting]
PATH = ["greeting/:name"]
":name" = "Literal"
DOC = """
Return a greeting personalized for `name`.
"""

[route.setgreeting]
PATH = ["greeting/:greeting"]
METHOD = "POST"
":greeting" = "Literal"
DOC = """
Set the personalized greeting to return from [greeting](#greeting).
"""
9 changes: 8 additions & 1 deletion examples/hello-world/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use serde::{Deserialize, Serialize};
use snafu::Snafu;
use std::fs;
use std::io;
use std::path::PathBuf;
use std::str::FromStr;
use tide_disco::{http::StatusCode, Api, App, Error, RequestError};
use tracing::info;

Expand Down Expand Up @@ -41,7 +43,12 @@ async fn serve(port: u16) -> io::Result<()> {
"examples/hello-world/api.toml",
)?)?)
.unwrap();
api.with_version(env!("CARGO_PKG_VERSION").parse().unwrap());
api.with_version(env!("CARGO_PKG_VERSION").parse().unwrap())
.with_public(
PathBuf::from_str(env!("CARGO_MANIFEST_DIR"))
.unwrap()
.join("public/media"),
);

// Can invoke by browsing
// `http://0.0.0.0:8080/hello/greeting/dude`
Expand Down
Loading

0 comments on commit fae7016

Please sign in to comment.