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;
|
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]
|
#[tracing::instrument]
|
||||||
@ -85,14 +89,19 @@ async fn static_assets(Path(path): Path<String>) -> Response {
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
#[cfg(feature = "console-subscriber")]
|
#[cfg(feature = "console-subscriber")]
|
||||||
|
{
|
||||||
tracing_subscriber::registry()
|
tracing_subscriber::registry()
|
||||||
.with(console_subscriber::spawn())
|
.with(console_subscriber::spawn())
|
||||||
.with(tracing_subscriber::fmt::layer())
|
.with(tracing_subscriber::fmt::layer())
|
||||||
.init();
|
.init();
|
||||||
|
tracing::debug!("console subscriber configured successfully");
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "console-subscriber"))]
|
#[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 api_router = axum::Router::new();
|
||||||
let oauth_router = axum::Router::new();
|
let oauth_router = axum::Router::new();
|
||||||
|
|
||||||
@ -107,21 +116,24 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
// with login
|
// with login
|
||||||
.route("/networks", axum::routing::get(rendering_pages))
|
.route("/networks", axum::routing::get(rendering_pages))
|
||||||
// nesting router
|
// nesting router
|
||||||
.nest("/api/", api_router)
|
.nest("/api", api_router)
|
||||||
.nest("/o/", oauth_router)
|
.nest("/o", oauth_router)
|
||||||
.nest("/sse", sse_router)
|
.nest("/sse", sse_router)
|
||||||
// fallback
|
// fallback
|
||||||
.fallback(rendering_pages)
|
.fallback(rendering_pages)
|
||||||
.layer(
|
.layer(
|
||||||
tower::ServiceBuilder::new().layer(
|
tower::ServiceBuilder::new()
|
||||||
|
.layer(
|
||||||
tower_http::trace::TraceLayer::new_for_http()
|
tower_http::trace::TraceLayer::new_for_http()
|
||||||
.make_span_with(DefaultMakeSpan::new().level(Level::INFO))
|
.make_span_with(DefaultMakeSpan::new().level(Level::INFO))
|
||||||
.on_request(DefaultOnRequest::new().level(Level::INFO))
|
.on_request(DefaultOnRequest::new().level(Level::INFO))
|
||||||
.on_response(DefaultOnResponse::new().level(Level::INFO)),
|
.on_response(DefaultOnResponse::new().level(Level::INFO)),
|
||||||
).catch_panic(),
|
)
|
||||||
|
.catch_panic(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:1234").await?;
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:1234").await?;
|
||||||
|
tracing::info!("listening on {}", listener.local_addr()?);
|
||||||
axum::serve(listener, router).await?;
|
axum::serve(listener, router).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -3,7 +3,6 @@ use std::collections::HashMap;
|
|||||||
use yew::{function_component, html, Html};
|
use yew::{function_component, html, Html};
|
||||||
use yew_router::history::History;
|
use yew_router::history::History;
|
||||||
|
|
||||||
|
|
||||||
#[derive(yew_router::Routable, PartialEq, Eq, Clone, Debug)]
|
#[derive(yew_router::Routable, PartialEq, Eq, Clone, Debug)]
|
||||||
pub enum Route {
|
pub enum Route {
|
||||||
#[at("/")]
|
#[at("/")]
|
||||||
@ -30,8 +29,8 @@ fn switch(routes: Route) -> Html {
|
|||||||
|
|
||||||
#[function_component]
|
#[function_component]
|
||||||
pub fn Layout() -> Html {
|
pub fn Layout() -> Html {
|
||||||
use yew_router::Switch;
|
|
||||||
use super::components::Nav;
|
use super::components::Nav;
|
||||||
|
use yew_router::Switch;
|
||||||
html! {
|
html! {
|
||||||
<>
|
<>
|
||||||
<Nav />
|
<Nav />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
use crate::app::Route;
|
||||||
use yew::{classes, function_component, html, use_state_eq, Callback, Html, MouseEvent};
|
use yew::{classes, function_component, html, use_state_eq, Callback, Html, MouseEvent};
|
||||||
use yew_router::{components::Link, hooks::use_location, Routable};
|
use yew_router::{components::Link, hooks::use_location, Routable};
|
||||||
use crate::app::Route;
|
|
||||||
|
|
||||||
#[function_component(Nav)]
|
#[function_component(Nav)]
|
||||||
pub fn nav_bar() -> Html {
|
pub fn nav_bar() -> Html {
|
||||||
@ -8,7 +8,20 @@ pub fn nav_bar() -> Html {
|
|||||||
let show_dropdown_handle = show_dropdown.clone();
|
let show_dropdown_handle = show_dropdown.clone();
|
||||||
|
|
||||||
let mut dropdown_classes = vec![
|
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 {
|
if !*show_dropdown {
|
||||||
dropdown_classes.push("hidden");
|
dropdown_classes.push("hidden");
|
||||||
@ -24,7 +37,8 @@ pub fn nav_bar() -> Html {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let show_mobile_menu = use_state_eq(|| 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 (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"];
|
let mut mobile_menu_classes = vec!["sm:hidden"];
|
||||||
if *show_mobile_menu {
|
if *show_mobile_menu {
|
||||||
(mobile_icon, mobile_icon_expanded) = (mobile_icon_expanded, mobile_icon);
|
(mobile_icon, mobile_icon_expanded) = (mobile_icon_expanded, mobile_icon);
|
||||||
@ -68,7 +82,6 @@ pub fn nav_bar() -> Html {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
<nav class="bg-gray-800">
|
<nav class="bg-gray-800">
|
||||||
<div class="mx-auto max-w-7xl px-2 sm:px-6 lg:px-8">
|
<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 counter;
|
||||||
pub mod echo;
|
pub mod echo;
|
||||||
pub mod _404;
|
pub mod index;
|
||||||
|
|
||||||
pub use counter::CounterPage;
|
pub use counter::CounterPage;
|
||||||
pub use echo::EchoPage;
|
pub use echo::EchoPage;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use yew::{function_component, html, use_state_eq, Callback, Html};
|
use yew::{function_component, html, use_state_eq, Callback, Html};
|
||||||
|
|
||||||
|
|
||||||
#[function_component]
|
#[function_component]
|
||||||
pub fn IndexPage() -> Html {
|
pub fn IndexPage() -> Html {
|
||||||
let counter = use_state_eq(|| 1);
|
let counter = use_state_eq(|| 1);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use yew_agent::prelude::*;
|
|
||||||
use futures::sink::SinkExt;
|
use futures::sink::SinkExt;
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
|
use yew_agent::prelude::*;
|
||||||
|
|
||||||
#[reactor(Counter)]
|
#[reactor(Counter)]
|
||||||
pub async fn counter(mut scope: ReactorScope<(), u64>) {
|
pub async fn counter(mut scope: ReactorScope<(), u64>) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user