Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 13 additions & 122 deletions Cargo.lock

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

15 changes: 2 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
resolver = "2"

members = ["examples/todo-app/src/backend", "packages/ic-http-auth", "packages/local-replica"]
members = ["examples/todo-app/src/backend", "packages/ic-http", "packages/local-replica"]

[workspace.package]
version = "0.0.0"
Expand All @@ -25,35 +25,24 @@ panic = "unwind" # Keep unwinding for better debugging (optional)


[workspace.dependencies]
ic-http-auth = { path = "./packages/ic-http-auth", version = "0.0.0" }
ic-http = { path = "./packages/ic-http", version = "0.0.0" }

candid = "0.10"
ic-cdk = "0.18"
ic-http-certification = "3"
ic-asset-certification = "3"
ic-canister-sig-creation = "1"
ic-signature-verification = "0.2"

thiserror = "2"
base64 = "0.22"
serde = { version = "1", features = ["derive"] }
serde_json = "1"

once_cell = "1"
matchit = "=0.8.4"

sha2 = "0.10"
nom = "8"
include_dir = { version = "0.7", features = ["glob"] }

# debugging
hex = "0.4"

[workspace.dependencies.p256]
version = "0.13"
default-features = false
features = ["ecdsa", "jwk", "pkcs8"]

[workspace.lints.rust]
warnings = "deny"

Expand Down
2 changes: 1 addition & 1 deletion examples/todo-app/src/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ candid.workspace = true
ic-cdk.workspace = true
ic-http-certification.workspace = true
ic-asset-certification.workspace = true
ic-http-auth.workspace = true
ic-http.workspace = true

include_dir.workspace = true
hex.workspace = true
Expand Down
18 changes: 10 additions & 8 deletions examples/todo-app/src/backend/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
mod api;
mod assets;
mod root_key;
mod router;
mod todo;

Expand All @@ -10,24 +9,24 @@ use ic_cdk::*;
use ic_http_certification::{HttpRequest, HttpResponse};
use matchit::Router;
use once_cell::sync::OnceCell;
use root_key::init_root_key;
use router::MethodRouter;
use todo::*;

#[init]
fn init() {
init_root_key();
certify_all_assets();
}

#[post_upgrade]
fn post_upgrade() {
init_root_key();
certify_all_assets();
}

#[query]
fn http_request(req: HttpRequest) -> HttpResponse {
#[query(
decode_with = "ic_http::decode_args",
encode_with = "ic_http::encode_result"
)]
fn http_request_v2(req: HttpRequest) -> HttpResponse<'static> {
let path = req.get_path().expect("Failed to parse request path");

if path.starts_with("/api") {
Expand All @@ -38,8 +37,11 @@ fn http_request(req: HttpRequest) -> HttpResponse {
serve_asset(&req)
}

#[update]
fn http_request_update(req: HttpRequest) -> HttpResponse {
#[update(
decode_with = "ic_http::decode_args",
encode_with = "ic_http::encode_result"
)]
fn http_request_update_v2(req: HttpRequest) -> HttpResponse<'static> {
let path = req.get_path().expect("Failed to parse request path");

if path.starts_with("/api") {
Expand Down
Loading