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
13 changes: 13 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ hex = "0.4.3"
http = "1.2.0"
ic-canister-log = "0.2.0"
ic-cdk = "0.17.1"
ic-http-types = "0.1.0"
ic-ed25519 = "0.1.0"
ic-metrics-encoder = "1.1"
ic-stable-structures = "0.6.7"
Expand Down
1 change: 1 addition & 0 deletions canister/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ derive_more = { workspace = true }
hex = { workspace = true }
http = { workspace = true }
ic-cdk = { workspace = true }
ic-http-types = { workspace = true }
ic-metrics-encoder = { workspace = true }
ic-stable-structures = { workspace = true }
maplit = { workspace = true }
Expand Down
106 changes: 0 additions & 106 deletions canister/src/http_types/mod.rs

This file was deleted.

20 changes: 0 additions & 20 deletions canister/src/http_types/tests.rs

This file was deleted.

1 change: 0 additions & 1 deletion canister/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod candid_rpc;
pub mod constants;
pub mod http;
pub mod http_types;
pub mod lifecycle;
pub mod logs;
pub mod memory;
Expand Down
22 changes: 11 additions & 11 deletions canister/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use candid::candid_method;
use canlog::{log, Log, Sort};
use ic_cdk::{api::is_controller, query, update};
use ic_http_types::{HttpRequest, HttpResponse, HttpResponseBuilder};
use ic_metrics_encoder::MetricsEncoder;
use sol_rpc_canister::{
candid_rpc::send_multi,
http_types, lifecycle,
lifecycle,
logs::Priority,
memory::{mutate_state, read_state, State},
metrics::encode_metrics,
Expand Down Expand Up @@ -241,29 +242,28 @@ async fn json_request_cycles_cost(
}

#[query(hidden = true)]
fn http_request(request: http_types::HttpRequest) -> http_types::HttpResponse {
fn http_request(request: HttpRequest) -> HttpResponse {
match request.path() {
"/metrics" => {
let mut writer = MetricsEncoder::new(vec![], ic_cdk::api::time() as i64 / 1_000_000);

match encode_metrics(&mut writer) {
Ok(()) => http_types::HttpResponseBuilder::ok()
Ok(()) => HttpResponseBuilder::ok()
.header("Content-Type", "text/plain; version=0.0.4")
.with_body_and_content_length(writer.into_inner())
.build(),
Err(err) => http_types::HttpResponseBuilder::server_error(format!(
"Failed to encode metrics: {}",
err
))
.build(),
Err(err) => {
HttpResponseBuilder::server_error(format!("Failed to encode metrics: {}", err))
.build()
}
}
}
"/logs" => {
let max_skip_timestamp = match request.raw_query_param("time") {
Some(arg) => match u64::from_str(arg) {
Ok(value) => value,
Err(_) => {
return http_types::HttpResponseBuilder::bad_request()
return HttpResponseBuilder::bad_request()
.with_body_and_content_length("failed to parse the 'time' parameter")
.build()
}
Expand Down Expand Up @@ -307,12 +307,12 @@ fn http_request(request: http_types::HttpRequest) -> http_types::HttpResponse {
));

const MAX_BODY_SIZE: usize = 2_000_000;
http_types::HttpResponseBuilder::ok()
HttpResponseBuilder::ok()
.header("Content-Type", "application/json; charset=utf-8")
.with_body_and_content_length(log.serialize_logs(MAX_BODY_SIZE))
.build()
}
_ => http_types::HttpResponseBuilder::not_found().build(),
_ => HttpResponseBuilder::not_found().build(),
}
}

Expand Down
1 change: 1 addition & 0 deletions integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ canhttp = { workspace = true }
canlog = { path = "../canlog" }
const_format = { workspace = true }
ic-cdk = { workspace = true }
ic-http-types = { workspace = true }
ic-test-utilities-load-wasm = { workspace = true }
num-traits = { workspace = true }
pocket-ic = { workspace = true }
Expand Down
6 changes: 2 additions & 4 deletions integration_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use candid::{decode_args, encode_args, utils::ArgumentEncoder, CandidType, Encod
use canhttp::http::json::ConstantSizeId;
use canlog::{Log, LogEntry};
use ic_cdk::api::call::RejectionCode;
use ic_http_types::{HttpRequest, HttpResponse};
use num_traits::ToPrimitive;
use pocket_ic::{
common::rest::{
Expand All @@ -14,10 +15,7 @@ use pocket_ic::{
};
use regex::Regex;
use serde::{de::DeserializeOwned, Deserialize};
use sol_rpc_canister::{
http_types::{HttpRequest, HttpResponse},
logs::Priority,
};
use sol_rpc_canister::logs::Priority;
use sol_rpc_client::{ClientBuilder, Runtime, SolRpcClient};
use sol_rpc_types::{InstallArgs, RpcAccess, SupportedRpcProviderId};
use std::{
Expand Down
Loading