Skip to content

Commit

Permalink
git link
Browse files Browse the repository at this point in the history
  • Loading branch information
BERADQ committed Apr 8, 2024
1 parent bbf0c27 commit d82a779
Show file tree
Hide file tree
Showing 6 changed files with 340 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
kokoro = { version = "0.0.6", path = "../kokoro" }
kokoro = { version = "0.0.6", git = "https://github.com/kokoro-rs/kokoro.git" }
serde = { version = "1.0.196", features = ["derive"] }
kokoro-plugin-tiny-http-event = {path = "./kokoro-plugin-tiny-http-event"}

Expand Down
15 changes: 10 additions & 5 deletions examples/example.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use kokoro::{dynamic_plugin::toml::toml, prelude::*};
use std::fs::File;

use kokoro::{dynamic_plugin::toml::toml, prelude::*, core::query::EventQuery};
use kokoro_plugin_tiny_http_event::{http::Response, *};
fn main() -> Result<()> {
let ctx = channel_ctx();
Expand All @@ -9,15 +11,18 @@ fn main() -> Result<()> {
port = 1145
};
ctx.plugin_dynamic(plugin, Some(config.into()))?;
ctx.subscribe(hello);
ctx.subscribe(index);
ctx.run_sync();

Ok(())
}

path!(Hello, "/hello");
fn hello(req: PathQuery<Hello>) {
fn index(req: EventQuery<HttpRequest>) {
let url = &req.url;
if let Some(req) = req.take() {
req.respond(Response::from_string("Hello World!")).unwrap();
req.respond(Response::from_file(
File::open(format!(".{}", url)).unwrap(),
))
.unwrap();
}
}
2 changes: 2 additions & 0 deletions img.js

Large diffs are not rendered by default.

Loading

0 comments on commit d82a779

Please sign in to comment.