Page MenuHomePhabricator

D6861.diff
No OneTemporary

D6861.diff

diff --git a/services/feature-flags/Cargo.lock b/services/feature-flags/Cargo.lock
--- a/services/feature-flags/Cargo.lock
+++ b/services/feature-flags/Cargo.lock
@@ -878,6 +878,7 @@
"comm-services-lib",
"http",
"once_cell",
+ "serde",
"tokio",
"tracing",
"tracing-subscriber",
@@ -1708,6 +1709,20 @@
version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.152"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
[[package]]
name = "serde_json"
diff --git a/services/feature-flags/Cargo.toml b/services/feature-flags/Cargo.toml
--- a/services/feature-flags/Cargo.toml
+++ b/services/feature-flags/Cargo.toml
@@ -13,9 +13,10 @@
aws-types = "0.51.0"
aws-sdk-dynamodb = "0.21.0"
clap = { version = "4.0", features = ["derive", "env"] }
+comm-services-lib = { path = "../comm-services-lib" }
http = "0.2"
once_cell = "1.17"
-comm-services-lib = { path = "../comm-services-lib" }
+serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.24", features = ["rt-multi-thread", "macros"]}
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"]}
diff --git a/services/feature-flags/src/service.rs b/services/feature-flags/src/service.rs
--- a/services/feature-flags/src/service.rs
+++ b/services/feature-flags/src/service.rs
@@ -1,27 +1,41 @@
use crate::config::CONFIG;
use crate::database::{DatabaseClient, FeatureConfig, Platform};
-use actix_web::{web, App, HttpServer};
+use actix_web::{web, App, HttpResponse, HttpServer};
use comm_services_lib::database::Error;
+use serde::Deserialize;
use std::collections::HashSet;
pub struct FeatureFlagsService {
- _db: DatabaseClient,
+ db: DatabaseClient,
}
impl FeatureFlagsService {
pub fn new(db_client: DatabaseClient) -> Self {
- FeatureFlagsService { _db: db_client }
+ FeatureFlagsService { db: db_client }
}
pub async fn start(&self) -> std::io::Result<()> {
- HttpServer::new(|| {
- App::new().service(web::resource("/").to(|| async { "HELLO" }))
+ let db_clone = self.db.clone();
+ HttpServer::new(move || {
+ App::new()
+ .app_data(web::Data::new(db_clone.to_owned()))
+ .service(
+ web::resource("/features")
+ .route(web::get().to(Self::features_handler)),
+ )
})
.bind(("localhost", CONFIG.http_port))?
.run()
.await
}
+ async fn features_handler(
+ _client: web::Data<DatabaseClient>,
+ _query: web::Query<FeatureQuery>,
+ ) -> Result<HttpResponse, actix_web::Error> {
+ Ok(HttpResponse::Ok().body("HELLO"))
+ }
+
async fn _enabled_features_set(
db: &DatabaseClient,
platform: Platform,
@@ -66,3 +80,11 @@
})
}
}
+
+#[allow(dead_code)]
+#[derive(Deserialize, Debug)]
+struct FeatureQuery {
+ code_version: i32,
+ is_staff: bool,
+ platform: String,
+}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 4:07 PM (21 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605492
Default Alt Text
D6861.diff (3 KB)

Event Timeline