Skip to main content

Module evm_profile_server

Module evm_profile_server 

Source
Expand description

Local HTTP server for serving EVM profiles to speedscope.app.

This module implements a temporary local HTTP server that:

  1. Serves the profile JSON at /{token}/profile.json
  2. Sets CORS headers to allow the viewer to fetch it
  3. Constructs the proper URL and opens it in the browser

Re-exportsยง

use axum::Router; ๐Ÿ”’
use axum::body::Bytes; ๐Ÿ”’
use axum::extract::State; ๐Ÿ”’
use axum::http::Method; ๐Ÿ”’
use axum::http::StatusCode; ๐Ÿ”’
use axum::http::header; ๐Ÿ”’
use axum::response::IntoResponse; ๐Ÿ”’
use axum::response::Response; ๐Ÿ”’
use axum::routing::get; ๐Ÿ”’
use eyre::Result; ๐Ÿ”’
use foundry_common::sh_err; ๐Ÿ”’
use foundry_common::sh_println; ๐Ÿ”’
use std::hash::DefaultHasher; ๐Ÿ”’
use std::hash::Hasher; ๐Ÿ”’
use std::time::SystemTime; ๐Ÿ”’
use std::time::UNIX_EPOCH; ๐Ÿ”’
use tokio::net::TcpListener; ๐Ÿ”’
use tower_http::cors::Any; ๐Ÿ”’
use tower_http::cors::CorsLayer; ๐Ÿ”’

Functionsยง

generate_token ๐Ÿ”’
Generates a random token for the URL path (32 hex characters).
percent_encode ๐Ÿ”’
Percent-encode a URL for embedding in viewer URL parameters.
serve_and_open
Serves a profile on a local HTTP server and opens it in the browser.
serve_profile ๐Ÿ”’