-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* folder structure created and routes configured * stale constants removed * stale constants removed * cache cleared * duplicate function removed * Updated README.md * framework changed to actix-web * accidental removal restored
- Loading branch information
1 parent
fda081d
commit e85b27e
Showing
11 changed files
with
448 additions
and
521 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,10 @@ | ||
[package] | ||
name = "rust-shield" | ||
name = "shield" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "MIT AND Apache-2.0" | ||
description = "This is going to be an IAM system. Just reserving the name for time being." | ||
documentation = "https://shield-docs.rustsea.com" | ||
homepage = "https://www.rustsea.com/shield" | ||
keywords = ["auth", "iam-provider", "identity-and-access", "idp"] | ||
readme = "README.md" | ||
repository = "https://github.com/rustsea/shield/" | ||
|
||
[dependencies] | ||
rocket = "0.5.0-rc.3" | ||
shuttle-rocket = "0.28.0" | ||
actix-web = "4.3.1" | ||
shuttle-actix-web = "0.28.0" | ||
shuttle-runtime = "0.28.0" | ||
tokio = "1.32.0" | ||
tokio = "1.26.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,21 @@ | ||
mod routes; | ||
use actix_web::{get, web::{ServiceConfig, scope}}; | ||
use shuttle_actix_web::ShuttleActixWeb; | ||
use crate::organisation::factory::organisation_factory; | ||
|
||
mod organisation; | ||
mod project; | ||
|
||
use routes::{get_routes, RouteKey}; | ||
use organisation::{index as org_index}; | ||
use project::{index as project_index}; | ||
|
||
#[macro_use] | ||
extern crate rocket; | ||
|
||
#[shuttle_runtime::main] | ||
async fn rocket() -> shuttle_rocket::ShuttleRocket { | ||
let rocket = rocket::build() | ||
.mount("/", routes![index]) | ||
.mount(&get_path(&RouteKey::Organisations), routes![org_index]) | ||
.mount(&get_path(&RouteKey::Projects), routes![project_index]); | ||
Ok(rocket.into()) | ||
} | ||
|
||
#[get("/")] | ||
fn index() -> &'static str { | ||
#[get("")] | ||
async fn hello_world() -> &'static str { | ||
"Hello World! It's your Shield" | ||
} | ||
|
||
fn get_path(route: &RouteKey) -> String { | ||
let routes_map = get_routes(); | ||
routes_map.get(route).map(|s|s.to_string()).expect("Route not found") | ||
#[shuttle_runtime::main] | ||
async fn actix_web() -> ShuttleActixWeb<impl FnOnce(&mut ServiceConfig) + Send + Clone + 'static> { | ||
let config = move |cfg: &mut ServiceConfig| { | ||
cfg.service(scope("/").service(hello_world)) | ||
.service(scope("/organisations").service(organisation_factory())); | ||
}; | ||
|
||
Ok(config.into()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
#[get("/")] | ||
pub fn index() -> &'static str { | ||
"Hello from Shield, this is Organisations Route" | ||
} | ||
use actix_web::{get, HttpResponse, Result}; | ||
use actix_web::web::Path; | ||
|
||
#[get("")] | ||
pub async fn index() -> Result<HttpResponse> { | ||
Ok(HttpResponse::Ok().body("Hello from the organization index!")) | ||
} | ||
|
||
#[get("/{organisation_id}")] | ||
pub async fn org_info(path: Path<String>) -> Result<HttpResponse> { | ||
Ok(HttpResponse::Ok().body(format!("Your organisation id: {}", path))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use actix_web::{Scope, web}; | ||
use crate::organisation::controller::{index, org_info}; | ||
use crate::project::factory::project_factory; | ||
|
||
pub fn organisation_factory () -> Scope { | ||
web::scope("") | ||
.service(index) | ||
.service(org_info) | ||
.service(web::scope("/{organisation_id}/projects").service(project_factory())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
mod controller; | ||
|
||
pub use controller::{index}; | ||
pub mod controller; | ||
pub mod factory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
#[get("/")] | ||
pub fn index() -> &'static str { | ||
"Hello from Shield, this is Projects Route" | ||
} | ||
use actix_web::{get, HttpResponse, Result}; | ||
use actix_web::web::Path; | ||
|
||
#[get("")] | ||
pub async fn index() -> Result<HttpResponse> { | ||
Ok(HttpResponse::Ok().body("Hello from Shield, this is Projects Route")) | ||
} | ||
|
||
#[get("/{project_id}")] | ||
pub async fn project_info(path: Path<(String, String)>) -> Result<HttpResponse> { | ||
let (organisation_id, project_id) = path.into_inner(); | ||
Ok(HttpResponse::Ok().body(format!("Your project id is: {} belongs to: {}", project_id, organisation_id))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use actix_web::{Scope, web}; | ||
use crate::project::controller::{index, project_info}; | ||
|
||
pub fn project_factory () -> Scope { | ||
web::scope("") | ||
.service(index) | ||
.service(project_info) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
mod controller; | ||
|
||
pub use controller::{index}; | ||
pub mod controller; | ||
pub mod factory; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.