Skip to content

FireTail-io/firetail-rust-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Rust Library

  • Note: The library is built for actix at the moment

Before running this library

  • Make sure there are firetail environment variables. The two environment variables needed are:
  1. FIRETAIL_APIKEY - This is the API Key used to communicate with firetail servers
  2. FIRETAIL_URL - This is the firetail backend URL, which can be set the US Platform and by default it points to EU (Europe) Platform. If you are using the US Platform, it is recommended to set it to https://api.logging.us-east-2.prod.us.firetail.app

Example code to run it with actix

use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};
use firetail_rust_lib::FiretailLogging;

#[get("/")]
async fn hello() -> impl Responder {
    HttpResponse::Ok().body("Hello world!")
}

#[post("/echo")]
async fn echo(req_body: String) -> impl Responder {
    HttpResponse::Ok().body(req_body)
}

async fn manual_hello() -> impl Responder {
    HttpResponse::Ok().body("Hey there!")
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new()
            .wrap(FiretailLogging::default())
            .service(hello)
            .service(echo)
            .route("/hey", web::get().to(manual_hello))
    })
    .bind(("127.0.0.1", 8080))?
    .run()
    .await
}

You will need to include the firetail library in Cargo.toml

firetail-rust-lib = "0.0.1"

then add the library in your actix's main.rs

use firetail_actix_lib::FiretailLogging;

then activate firetail in your http code:

    HttpServer::new(|| {
        App::new()
            .wrap(FiretailLogging::default())
            .service(hello)
            .service(echo)
            .route("/hey", web::get().to(manual_hello))
    })

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages