Crates.io | lokal-rs |
lib.rs | lokal-rs |
version | 0.0.1 |
source | src |
created_at | 2024-07-30 05:04:04.597047 |
updated_at | 2024-07-30 05:04:04.597047 |
description | Rust crates for interacting with Lokal.so Client REST API |
homepage | https://lokal.so/?ref=rust-crates |
repository | https://github.com/lokal-so/lokal-rs |
max_upload_size | |
id | 1319464 |
size | 612,937 |
Rust crates for interacting with Lokal Client REST API
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!"
}