added tasting code
This commit is contained in:
3
.devcontainer/Dockerfile
Normal file
3
.devcontainer/Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
FROM rust:1-bookworm
|
||||||
|
RUN apt update && apt upgrade -y && apt install fish -y
|
||||||
|
RUn rustup component add clippy rustfmt
|
||||||
55
.devcontainer/devcontainer.json
Normal file
55
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||||
|
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
|
||||||
|
{
|
||||||
|
"name": "Rust",
|
||||||
|
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||||
|
"dockerComposeFile": "docker-compose.yml",
|
||||||
|
"service": "app",
|
||||||
|
"workspaceFolder": "/workspace",
|
||||||
|
|
||||||
|
// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
|
||||||
|
// "mounts": [
|
||||||
|
// {
|
||||||
|
// "source": "devcontainer-cargo-cache-${devcontainerId}",
|
||||||
|
// "target": "/usr/local/cargo",
|
||||||
|
// "type": "volume"
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
|
||||||
|
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||||
|
// "features": {
|
||||||
|
// "ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {}
|
||||||
|
// },
|
||||||
|
"mounts": [
|
||||||
|
"source=/home/tobi/.ssh,target=/home/vscode/.ssh,type=bind"
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
|
// "forwardPorts": [],
|
||||||
|
|
||||||
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
|
//"postCreateCommand": "git clone https://gitea.maiertobi.de/tobimai/dotfiles.git /home/vscode/dotfiles && cargo install cargo-tarpaulin",
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"extensions": [
|
||||||
|
"serayuzgur.crates",
|
||||||
|
"tamasfe.even-better-toml",
|
||||||
|
"vadimcn.vscode-lldb",
|
||||||
|
"mutantdino.resourcemonitor",
|
||||||
|
"rust-lang.rust-analyzer",
|
||||||
|
"ms-azuretools.vscode-docker"
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"terminal.integrated.defaultProfile.linux": "Fish",
|
||||||
|
"terminal.integrated.profiles.linux": {
|
||||||
|
"Fish": {
|
||||||
|
"path": "fish"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||||
|
// "remoteUser": "root"
|
||||||
|
}
|
||||||
32
.devcontainer/docker-compose.yml
Normal file
32
.devcontainer/docker-compose.yml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: .devcontainer/Dockerfile
|
||||||
|
volumes:
|
||||||
|
- ..:/workspace:cached
|
||||||
|
command: sleep infinity
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: postgres
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: dev
|
||||||
|
POSTGRES_PASSWORD: dev
|
||||||
|
POSTGRES_DB: iot
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
command: ["postgres", "-c", "log_statement=all"]
|
||||||
|
|
||||||
|
adminer:
|
||||||
|
image: michalhosna/adminer
|
||||||
|
environment:
|
||||||
|
ADMINER_DB: iot
|
||||||
|
ADMINER_DRIVER: pgsql
|
||||||
|
ADMINER_SERVER: db
|
||||||
|
ADMINER_USERNAME: dev
|
||||||
|
ADMINER_PASSWORD: dev
|
||||||
|
ADMINER_AUTOLOGIN: 1
|
||||||
|
ADMINER_NAME: IOT DEVELOPMENT
|
||||||
|
ports:
|
||||||
|
- 1111:8080
|
||||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -14,3 +14,8 @@ Cargo.lock
|
|||||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||||
*.pdb
|
*.pdb
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Added by cargo
|
||||||
|
|
||||||
|
/target
|
||||||
|
|||||||
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "iot-cloud"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
actix-web = "4.4.0"
|
||||||
|
sqlx = { version = "0.7", features = [ "runtime-tokio", "tls-rustls", "postgres" ] }
|
||||||
19
src/main.rs
Normal file
19
src/main.rs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
use actix_web::{get, web, App, HttpServer, Responder};
|
||||||
|
|
||||||
|
#[get("/")]
|
||||||
|
async fn index() -> impl Responder {
|
||||||
|
"Hello, World!"
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("/{name}")]
|
||||||
|
async fn hello(name: web::Path<String>) -> impl Responder {
|
||||||
|
format!("Hello {}!", &name)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[actix_web::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
|
HttpServer::new(|| App::new().service(index).service(hello))
|
||||||
|
.bind(("127.0.0.1", 8080))?
|
||||||
|
.run()
|
||||||
|
.await
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user