feat: create server folder

This commit is contained in:
dboures 2023-03-06 01:11:15 -06:00
parent 3866211c85
commit b3a9c5ceee
No known key found for this signature in database
GPG Key ID: AB3790129D478852
6 changed files with 1979 additions and 4 deletions

View File

@ -3109,7 +3109,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "openbook-candles"
name = "openbook-candle-creator"
version = "0.1.0"
dependencies = [
"anchor-client",

View File

@ -1,5 +1,5 @@
[package]
name = "openbook-candles"
name = "openbook-candle-creator"
version = "0.1.0"
edition = "2021"

1
server/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1935
server/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

11
server/Cargo.toml Normal file
View File

@ -0,0 +1,11 @@
[package]
name = "openbook-candle-server"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0"
actix-web = "4.3.1"
sqlx = { version = "0.6", features = [ "runtime-tokio-native-tls" , "postgres" ] }

View File

@ -1,3 +1,31 @@
fn main() {
println!("Hello, world!");
use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder, middleware::Logger};
#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().body("Hello world!")
}
#[post("/echo")]
async fn echo(req_body: String) -> impl Responder {
HttpResponse::Ok().body(req_body)
}
async fn manual_hello() -> impl Responder {
HttpResponse::Ok().body("Hey there!")
}
#[actix_web::main]
async fn main() -> anyhow::Result<()> {
HttpServer::new(|| {
App::new()
.wrap(Logger::default())
.service(hello)
.service(echo)
.route("/hey", web::get().to(manual_hello))
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}