这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
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
21 changes: 21 additions & 0 deletions examples/x.com/x_post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ const USER_AGENT: &str = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KH
const NOTARY_HOST: &str = "127.0.0.1:7047";

#[tokio::main]
/// Asynchronously initializes connections and sends a notarized HTTP request to retrieve a Twitter post.
///
/// This function sets up logging and loads the required environment variables for authentication.
/// It then requests notarization from a notary service, configures a Prover for TLS negotiation,
/// establishes a TCP and TLS connection, and initiates an HTTP/1 handshake. Finally, it constructs an
/// HTTP request with the proper headers to fetch a JSON representation of a Twitter post (based on
/// the POST_ID environment variable), defers decryption, and asserts that the response status is OK.
///
/// # Examples
///
/// ```no_run
/// // Before running, ensure that POST_ID, AUTH_TOKEN, ACCESS_TOKEN, and CSRF_TOKEN
/// // environment variables are properly set.
/// #[tokio::main]
/// async fn run() {
/// // Call the asynchronous main function to execute the notarization and HTTP request process.
/// your_crate::x_post::main().await;
/// }
///
/// run();
/// ```
async fn main() {
tracing_subscriber::fmt::init();

Expand Down