fixed compilation errors
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
use actix_web::web::Json;
|
use actix_web::web::Json;
|
||||||
use serde_json::json;
|
use serde::{Deserialize, Serialize};
|
||||||
|
include!("../models/location.rs");
|
||||||
|
|
||||||
async fn get_locations() -> impl Responder {
|
async fn get_locations() -> impl Responder {
|
||||||
let locations = vec![];
|
let locations: Vec<Location> = vec![];
|
||||||
Json(locations)
|
Json(locations)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
src/main.rs
12
src/main.rs
@@ -1,12 +1,20 @@
|
|||||||
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
|
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
|
||||||
|
include!("handlers/locations.rs");
|
||||||
|
|
||||||
async fn index() -> impl Responder { "Connection successful" }
|
async fn index(req: HttpRequest) -> impl Responder { "Connection successful" }
|
||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
.service(web::resource("/").to(index))
|
.route("/", web::get().to(index))
|
||||||
|
.service(
|
||||||
|
web::scope("/api/v1")
|
||||||
|
.service(web::resource("/locations").to(|| {
|
||||||
|
get_locations()
|
||||||
|
}))
|
||||||
|
.service(web::resource("/locations").route(web::post().to(create_location)))
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8080")?
|
.bind("127.0.0.1:8080")?
|
||||||
.run()
|
.run()
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
use serde::{Serialize, Deserialize};
|
|
||||||
use sqlx::Type;
|
use sqlx::Type;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Type)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Type)]
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
use serde::Deserialize;
|
|
||||||
use bigdecimal::BigDecimal;
|
use bigdecimal::BigDecimal;
|
||||||
|
include!("battery_status.rs");
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
struct Location {
|
struct Location {
|
||||||
latitude: BigDecimal,
|
latitude: BigDecimal,
|
||||||
longitude: BigDecimal,
|
longitude: BigDecimal,
|
||||||
accuracy: <Option>BigDecimal,
|
accuracy: Option<BigDecimal>,
|
||||||
altitude: <Option>BigDecimal,
|
altitude: Option<BigDecimal>,
|
||||||
velocity: <Option>BigDecimal,
|
velocity: Option<BigDecimal>,
|
||||||
battery_level: i16,
|
battery_level: i16,
|
||||||
battery_status: BatteryStatus,
|
battery_status: BatteryStatus,
|
||||||
timestamp: i64,
|
timestamp: i64,
|
||||||
bearing: <Option>BigDecimal,
|
bearing: Option<BigDecimal>,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user