Skip to content

Commit

Permalink
finalize
Browse files Browse the repository at this point in the history
  • Loading branch information
NotThatRqd committed Oct 29, 2023
1 parent 0fb0ba5 commit 2664a6d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[package]
name = "btnify"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
description = "Hosts a website with buttons for you so you can focus on what matters!"
license = "MIT"
repository = "https://github.com/NotThatRqd/btnify"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
axum = { version = "0.6.20", features = ["macros"] }
axum = { version = "0.6.20" }
hyper = { version = "0.14.27" }
serde = { version = "1.0.189", features = ["derive"] }
serde_json = "1.0.107"
1 change: 1 addition & 0 deletions src/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize};
/// returns `ButtonResponse`. It will be called whenever this button is pressed.
///
/// # Examples
///
/// ```
/// use btnify::button::{Button, ButtonResponse};
///
Expand Down
8 changes: 5 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ pub mod button;

/// Start your btnify server on the specified address with the specified buttons.
///
/// When a button is clicked its handler will be given a reference to user_state.
pub async fn bind_server<S: Send + Sync + 'static>(addr: &SocketAddr, buttons: Vec<Button<S>>, user_state: S) {
/// # Errors
///
/// Returns an error if there is a problem actually running the HTTP server, like if the address
/// is already being used by another application.
pub async fn bind_server<S: Send + Sync + 'static>(addr: &SocketAddr, buttons: Vec<Button<S>>, user_state: S) -> hyper::Result<()> {
let page = Html(create_page_html(buttons.iter()));

let buttons_map = buttons
Expand All @@ -34,7 +37,6 @@ pub async fn bind_server<S: Send + Sync + 'static>(addr: &SocketAddr, buttons: V
axum::Server::bind(addr)
.serve(app.into_make_service())
.await
.unwrap();
}

async fn get_root<S: Send + Sync>(State(state): State<Arc<BtnifyState<S>>>) -> Html<String> {
Expand Down

0 comments on commit 2664a6d

Please sign in to comment.