Nothing Special   »   [go: up one dir, main page]

Skip to content

Rust Crate for interacting with Lokal Client REST API

License

Notifications You must be signed in to change notification settings

lokal-so/lokal-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lokal Rust

Rust crates for interacting with Lokal Client REST API

Lokal Screenshot Lokal Address Bar

use lokal_rs::lokal::Lokal;
use lokal_rs::tunnel::{Tunnel, TunnelType};

use axum::{routing::get, Router};
use tokio;

#[tokio::main]
async fn main() {
    let address = "0.0.0.0:3000";

    let lokal = Lokal::new_default();

    let mut tunnel = Tunnel::new(lokal)
        .set_local_address(address.to_string())
        .set_tunnel_type(TunnelType::HTTP)
        .set_inspection(true)
        .set_lan_address("axum-backend.local".to_string())
        .set_public_address("axum.k.lokal-so.site".to_string())
        .set_name("Axum Backend".to_string())
        .ignore_duplicate()
        .show_startup_banner();

    match tunnel.create().await {
        Ok(_) => println!("Tunnel created successfully!"),
        Err(e) => println!("Error creating tunnel: {}", e),
    }

    let app = Router::new()
        .route("/", get(root));

    let listener = tokio::net::TcpListener::bind(address).await.unwrap();
    axum::serve(listener, app).await.unwrap();
}

// basic handler that responds with a static string
async fn root() -> &'static str {
    "Hello, World!"
}

About

Rust Crate for interacting with Lokal Client REST API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages