fn app() -> Router {
    let ws_routes = Router::new().route(
        "/backend",
        get(handlers::backend_ws_handler).layer(RequireAuthorizationLayer::custom(auth::HiveAuth)),
    );

    let graphql_routes = Router::new()
        .route("/backend", post(handlers::graphql_backend))
        .layer(Extension(backend::build_schema()));
    println!("{}", backend::build_schema().sdl());

    Router::new()
    // Static fileserver used to host the hive-backend-ui Vue app
    .fallback(routing::get_service(ServeDir::new(STATIC_FILES)).handle_error(
        |error: std::io::Error| async move {
            (
                StatusCode::INTERNAL_SERVER_ERROR,
                format!("Failed to fetch static files, this is likely due to a bug in the software or wrong software setup: {}", error),
            )
        },
    ))
    // Auth handler to get tokens for websocket connection establishment
    .route("/auth", post(auth::ws_auth_handler))
    // Websocket handler for backend UI
    .nest("/ws", ws_routes)
    .nest("/graphql", graphql_routes)
}
/// Builds the webserver with all endpoints
Builds the webserver with all endpoints
Builds the webserver with all endpoints
fn app() -> Router {
    let ws_routes = Router::new().route(
        "/backend",
        get(handlers::backend_ws_handler).layer(RequireAuthorizationLayer::custom(auth::HiveAuth)),
    );
    let graphql_routes = Router::new()
        .route("/backend", post(handlers::graphql_backend))
        .layer(Extension(backend::build_schema()));
    println!("{}", backend::build_schema().sdl());
    Router::new()
    // Static fileserver used to host the hive-backend-ui Vue app
    .fallback(routing::get_service(ServeDir::new(STATIC_FILES)).handle_error(
        |error: std::io::Error| async move {
            (
                StatusCode::INTERNAL_SERVER_ERROR,
                format!("Failed to fetch static files, this is likely due to a bug in the software or wrong software setup: {}", error),
            )
        },
    ))
    // Auth handler to get tokens for websocket connection establishment
    .route("/auth", post(auth::ws_auth_handler))
    // Websocket handler for backend UI
    .nest("/ws", ws_routes)
    .nest("/graphql", graphql_routes)
}
fn app ( ) -> Router { let ws_routes = Router :: new ( ) . route ( " " , get ( handlers :: backend_ws_handler ) . layer ( RequireAuthorizationLayer :: custom ( auth :: HiveAuth ) ) , ) ; let graphql_routes = Router :: new ( ) . route ( " " , post ( handlers :: graphql_backend ) ) . layer ( Extension ( backend :: build_schema ( ) ) ) ; println ! ( " " backend build_schema ( ) sdl ( ) ) ; Router :: new ( ) // Static fileserver used to host the hive-backend-ui Vue app . fallback ( routing :: get_service ( ServeDir :: new ( STATIC_FILES ) ) . handle_error ( | error : std :: io :: Error | async move { ( StatusCode :: INTERNAL_SERVER_ERROR , format ! ( " " error ) , ) } , ) ) // Auth handler to get tokens for websocket connection establishment . route ( " " , post ( auth :: ws_auth_handler ) ) // Websocket handler for backend UI . nest ( " " , ws_routes ) . nest ( " " , graphql_routes ) }
Builds the webserver with all endpoints
Builds the webserver with all endpoints