cargo fmt and some minor formatting
This commit is contained in:
parent
d0cc4f33a6
commit
c25c63517a
@ -62,7 +62,11 @@ async fn rendering_pages(
|
||||
};
|
||||
|
||||
let rendered = renderer.render().await;
|
||||
(status_code, Html::from(INDEX_PAGE.replace("<!--inject-->", &rendered))).into_response()
|
||||
(
|
||||
status_code,
|
||||
Html::from(INDEX_PAGE.replace("<!--inject-->", &rendered)),
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
@ -85,14 +89,19 @@ async fn static_assets(Path(path): Path<String>) -> Response {
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
#[cfg(feature = "console-subscriber")]
|
||||
tracing_subscriber::registry()
|
||||
.with(console_subscriber::spawn())
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
.init();
|
||||
{
|
||||
tracing_subscriber::registry()
|
||||
.with(console_subscriber::spawn())
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
.init();
|
||||
tracing::debug!("console subscriber configured successfully");
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "console-subscriber"))]
|
||||
tracing_subscriber::fmt().init();
|
||||
|
||||
{
|
||||
tracing_subscriber::fmt().init();
|
||||
tracing::debug!("simple subscriber configured successfully");
|
||||
}
|
||||
let api_router = axum::Router::new();
|
||||
let oauth_router = axum::Router::new();
|
||||
|
||||
@ -107,21 +116,24 @@ async fn main() -> anyhow::Result<()> {
|
||||
// with login
|
||||
.route("/networks", axum::routing::get(rendering_pages))
|
||||
// nesting router
|
||||
.nest("/api/", api_router)
|
||||
.nest("/o/", oauth_router)
|
||||
.nest("/api", api_router)
|
||||
.nest("/o", oauth_router)
|
||||
.nest("/sse", sse_router)
|
||||
// fallback
|
||||
.fallback(rendering_pages)
|
||||
.layer(
|
||||
tower::ServiceBuilder::new().layer(
|
||||
tower_http::trace::TraceLayer::new_for_http()
|
||||
.make_span_with(DefaultMakeSpan::new().level(Level::INFO))
|
||||
.on_request(DefaultOnRequest::new().level(Level::INFO))
|
||||
.on_response(DefaultOnResponse::new().level(Level::INFO)),
|
||||
).catch_panic(),
|
||||
tower::ServiceBuilder::new()
|
||||
.layer(
|
||||
tower_http::trace::TraceLayer::new_for_http()
|
||||
.make_span_with(DefaultMakeSpan::new().level(Level::INFO))
|
||||
.on_request(DefaultOnRequest::new().level(Level::INFO))
|
||||
.on_response(DefaultOnResponse::new().level(Level::INFO)),
|
||||
)
|
||||
.catch_panic(),
|
||||
);
|
||||
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:1234").await?;
|
||||
tracing::info!("listening on {}", listener.local_addr()?);
|
||||
axum::serve(listener, router).await?;
|
||||
|
||||
Ok(())
|
||||
|
@ -3,7 +3,6 @@ use std::collections::HashMap;
|
||||
use yew::{function_component, html, Html};
|
||||
use yew_router::history::History;
|
||||
|
||||
|
||||
#[derive(yew_router::Routable, PartialEq, Eq, Clone, Debug)]
|
||||
pub enum Route {
|
||||
#[at("/")]
|
||||
@ -30,8 +29,8 @@ fn switch(routes: Route) -> Html {
|
||||
|
||||
#[function_component]
|
||||
pub fn Layout() -> Html {
|
||||
use yew_router::Switch;
|
||||
use super::components::Nav;
|
||||
use yew_router::Switch;
|
||||
html! {
|
||||
<>
|
||||
<Nav />
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::app::Route;
|
||||
use yew::{classes, function_component, html, use_state_eq, Callback, Html, MouseEvent};
|
||||
use yew_router::{components::Link, hooks::use_location, Routable};
|
||||
use crate::app::Route;
|
||||
|
||||
#[function_component(Nav)]
|
||||
pub fn nav_bar() -> Html {
|
||||
@ -8,7 +8,20 @@ pub fn nav_bar() -> Html {
|
||||
let show_dropdown_handle = show_dropdown.clone();
|
||||
|
||||
let mut dropdown_classes = vec![
|
||||
"absolute", "right-0", "z-10", "mt-2", "w-48", "origin-top-right", "rounded-md", "bg-white", "py-1", "shadow-lg", "ring-1", "ring-black", "ring-opacity-5", "focus:outline-none"
|
||||
"absolute",
|
||||
"right-0",
|
||||
"z-10",
|
||||
"mt-2",
|
||||
"w-48",
|
||||
"origin-top-right",
|
||||
"rounded-md",
|
||||
"bg-white",
|
||||
"py-1",
|
||||
"shadow-lg",
|
||||
"ring-1",
|
||||
"ring-black",
|
||||
"ring-opacity-5",
|
||||
"focus:outline-none",
|
||||
];
|
||||
if !*show_dropdown {
|
||||
dropdown_classes.push("hidden");
|
||||
@ -23,8 +36,9 @@ pub fn nav_bar() -> Html {
|
||||
show_dropdown_handle.set(false);
|
||||
});
|
||||
|
||||
let show_mobile_menu = use_state_eq(||false);
|
||||
let (mut mobile_icon, mut mobile_icon_expanded) = (vec!["h-6", "w-6", "block"], vec!["h-6", "w-6", "hidden"]);
|
||||
let show_mobile_menu = use_state_eq(|| false);
|
||||
let (mut mobile_icon, mut mobile_icon_expanded) =
|
||||
(vec!["h-6", "w-6", "block"], vec!["h-6", "w-6", "hidden"]);
|
||||
let mut mobile_menu_classes = vec!["sm:hidden"];
|
||||
if *show_mobile_menu {
|
||||
(mobile_icon, mobile_icon_expanded) = (mobile_icon_expanded, mobile_icon);
|
||||
@ -32,7 +46,7 @@ pub fn nav_bar() -> Html {
|
||||
mobile_menu_classes.push("hidden");
|
||||
}
|
||||
let show_mobile_menu_handler = show_mobile_menu.clone();
|
||||
let mobile_menu_toggler = Callback::from(move |_:MouseEvent| {
|
||||
let mobile_menu_toggler = Callback::from(move |_: MouseEvent| {
|
||||
show_mobile_menu_handler.set(!*show_mobile_menu_handler);
|
||||
});
|
||||
|
||||
@ -68,7 +82,6 @@ pub fn nav_bar() -> Html {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
html! {
|
||||
<nav class="bg-gray-800">
|
||||
<div class="mx-auto max-w-7xl px-2 sm:px-6 lg:px-8">
|
||||
|
@ -1,7 +1,7 @@
|
||||
pub mod index;
|
||||
pub mod _404;
|
||||
pub mod counter;
|
||||
pub mod echo;
|
||||
pub mod _404;
|
||||
pub mod index;
|
||||
|
||||
pub use counter::CounterPage;
|
||||
pub use echo::EchoPage;
|
||||
|
@ -1,6 +1,5 @@
|
||||
use yew::{function_component, html, use_state_eq, Callback, Html};
|
||||
|
||||
|
||||
#[function_component]
|
||||
pub fn IndexPage() -> Html {
|
||||
let counter = use_state_eq(|| 1);
|
||||
|
@ -1,6 +1,6 @@
|
||||
use yew_agent::prelude::*;
|
||||
use futures::sink::SinkExt;
|
||||
use futures::stream::StreamExt;
|
||||
use yew_agent::prelude::*;
|
||||
|
||||
#[reactor(Counter)]
|
||||
pub async fn counter(mut scope: ReactorScope<(), u64>) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user