network tab
This commit is contained in:
@@ -127,7 +127,6 @@ impl GurtHandler for AppHandler {
|
||||
};
|
||||
|
||||
log::info!("Handler started for {} {} from {}", ctx.method(), ctx.path(), ctx.remote_addr);
|
||||
log::info!("Handler type will be: {:?}", handler_type);
|
||||
|
||||
let result = match handler_type {
|
||||
HandlerType::Index => routes::index(app_state).await,
|
||||
@@ -337,7 +336,6 @@ async fn get_ca_certificate_content(app_state: &AppState) -> std::result::Result
|
||||
|
||||
async fn serve_static_file(ctx: &ServerContext) -> Result<GurtResponse> {
|
||||
let path = ctx.path();
|
||||
log::info!("Static file request for path: '{}'", path);
|
||||
|
||||
// Strip query parameters from the path for static file serving
|
||||
let path_without_query = if let Some(query_pos) = path.find('?') {
|
||||
@@ -355,7 +353,6 @@ async fn serve_static_file(ctx: &ServerContext) -> Result<GurtResponse> {
|
||||
path_without_query
|
||||
}
|
||||
};
|
||||
log::info!("Resolved file_path: '{}'", file_path);
|
||||
|
||||
if file_path.contains("..") || file_path.contains('/') || file_path.contains('\\') {
|
||||
log::warn!("Invalid file path requested: '{}'", file_path);
|
||||
@@ -367,11 +364,9 @@ async fn serve_static_file(ctx: &ServerContext) -> Result<GurtResponse> {
|
||||
.map_err(|_| GurtError::invalid_message("Failed to get current directory"))?;
|
||||
let frontend_dir = current_dir.join("frontend");
|
||||
let full_path = frontend_dir.join(file_path);
|
||||
log::info!("Attempting to read file: '{}'", full_path.display());
|
||||
|
||||
match tokio::fs::read_to_string(&full_path).await {
|
||||
Ok(content) => {
|
||||
log::info!("Successfully read file, content length: {} bytes", content.len());
|
||||
let content_type = match full_path.extension().and_then(|ext| ext.to_str()) {
|
||||
Some("html") => "text/html",
|
||||
Some("lua") => "text/plain",
|
||||
|
||||
@@ -21,30 +21,22 @@ fn parse_query_string(query: &str) -> HashMap<String, String> {
|
||||
}
|
||||
|
||||
pub(crate) async fn index(_app_state: AppState) -> Result<GurtResponse> {
|
||||
log::info!("Index handler called - attempting to serve index.html");
|
||||
|
||||
let current_dir = std::env::current_dir()
|
||||
.map_err(|_| GurtError::invalid_message("Failed to get current directory"))?;
|
||||
log::info!("Current directory: {}", current_dir.display());
|
||||
|
||||
let frontend_dir = current_dir.join("frontend");
|
||||
let index_path = frontend_dir.join("index.html");
|
||||
log::info!("Looking for index.html at: {}", index_path.display());
|
||||
|
||||
match tokio::fs::read_to_string(&index_path).await {
|
||||
Ok(content) => {
|
||||
log::info!("Successfully read index.html, content length: {} bytes", content.len());
|
||||
Ok(GurtResponse::ok()
|
||||
.with_header("Content-Type", "text/html")
|
||||
.with_string_body(&content))
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to read index.html: {}", e);
|
||||
Err(_) => {
|
||||
let body = format!(
|
||||
"GurtDNS v{}!\n\nThe available endpoints are:\n\n - [GET] /domains\n - [GET] /domain/{{name}}/{{tld}}\n - [POST] /domain\n - [PUT] /domain/{{key}}\n - [DELETE] /domain/{{key}}\n - [GET] /tlds\n\nRatelimits are as follows: 5 requests per 10 minutes on `[POST] /domain`.\n\nCode link: https://github.com/outpoot/gurted",
|
||||
env!("CARGO_PKG_VERSION")
|
||||
);
|
||||
log::info!("Serving fallback API info, length: {} bytes", body.len());
|
||||
Ok(GurtResponse::ok().with_string_body(&body))
|
||||
}
|
||||
}
|
||||
@@ -353,8 +345,6 @@ pub(crate) async fn get_user_domains(
|
||||
app_state: AppState,
|
||||
claims: Claims,
|
||||
) -> Result<GurtResponse> {
|
||||
log::info!("get_user_domains called for user_id: {} path: {}", claims.user_id, ctx.path());
|
||||
|
||||
// Parse pagination from query parameters
|
||||
let path = ctx.path();
|
||||
let query_params = if let Some(query_start) = path.find('?') {
|
||||
|
||||
Reference in New Issue
Block a user