Function feattle_ui::run_warp_server[][src]

pub async fn run_warp_server<F, P>(
    admin_panel: Arc<AdminPanel<F, P>>,
    addr: impl Into<SocketAddr> + 'static
) where
    F: Feattles<P> + Sync + Send + 'static,
    P: Persist + Sync + Send + 'static, 
Expand description

Run the given admin panel using warp framework.

To use it, make sure to activate the cargo feature "warp" in your Cargo.toml.

This will host the web UI under “/” and a JSON API under “/api/v1/” (see more at v1):

  • GET /api/v1/feattles
  • GET /api/v1/feattle/{key}
  • POST /api/v1/feattle/{key}

Example

use feattle_ui::{AdminPanel, run_warp_server};
use feattle_core::{feattles, Feattles};
use feattle_core::persist::NoPersistence;
use std::sync::Arc;

feattles! {
    struct MyToggles { a: bool, b: i32 }
}

// `NoPersistence` here is just a mock for the sake of the example
let my_toggles = Arc::new(MyToggles::new(NoPersistence));
let admin_panel = Arc::new(AdminPanel::new(my_toggles, "Project Panda - DEV".to_owned()));

run_warp_server(admin_panel, ([127, 0, 0, 1], 3030)).await;