V0.2 web api (#113)

* Adding dependencies

* Added web api code

* Some changes

* Code formatting

* Added dependencies

*   *

* Added workflow

* Changed branch to trigger workflows

* Added ssh key import

* Warning fixes
This commit was merged in pull request #113.
This commit is contained in:
KD
2025-03-30 15:00:07 -04:00
committed by GitHub
parent 9dd7ffa2b6
commit 6f320acb7c
3 changed files with 85 additions and 2 deletions
+38
View File
@@ -0,0 +1,38 @@
name: Rust CI
on:
push:
branches: [ "v0.2" ] # Changed from main to master
pull_request:
branches: [ "v0.2" ] # Changed from main to master
jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install Rust 1.85.0
uses: actions-rs/toolchain@v1
with:
toolchain: 1.85.0
components: clippy, rustfmt
override: true
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Build
run: |
mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitea_deploy_key
chmod 600 ~/.ssh/gitea_deploy_key
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
eval $(ssh-agent -s)
ssh-add -v ~/.ssh/gitea_deploy_key
cargo build --verbose --release
- name: Run tests
run: cargo test --verbose
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Run rustfmt
run: cargo fmt --all -- --check
+7
View File
@@ -4,3 +4,10 @@ version = "0.2.0"
edition = "2024"
[dependencies]
axum = { version = "0.8.3" }
serde = { version = "1.0.218", features = ["derive"] }
serde_json = { version = "1.0.139" }
tokio = { version = "1.44.1", features = ["rt-multi-thread"] }
tracing-subscriber = "0.3.19"
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.1.0-main-0dc8c153d2-680" }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.2.0" }
+40 -2
View File
@@ -1,3 +1,41 @@
fn main() {
println!("Hello, world!");
use axum::{
// Json,
Router,
// http::StatusCode,
// routing::{get, post},
routing::get,
};
// use serde::{Deserialize, Serialize};
#[tokio::main]
async fn main() {
// initialize tracing
tracing_subscriber::fmt::init();
// build our application with a route
let app = Router::new()
// `GET /` goes to `root`
.route("/", get(root));
// `POST /users` goes to `create_user`
// .route("/users", post(create_user));
// run our app with hyper, listening globally on port 3000
let listener = tokio::net::TcpListener::bind(get_full()).await.unwrap();
axum::serve(listener, app).await.unwrap();
}
fn get_full() -> String {
get_address() + ":" + &get_port()
}
fn get_address() -> String {
String::from("0.0.0.0")
}
fn get_port() -> String {
String::from("3000")
}
// basic handler that responds with a static string
async fn root() -> &'static str {
"Hello, World!"
}