Skip to content

Commit

Permalink
Add example curl commands to test each Organization handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jhodapp committed Nov 12, 2023
1 parent f387053 commit 6dcac29
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions web/src/controller/organization_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ pub struct OrganizationController {}

impl OrganizationController {
/// GET all Organizations
/// Test this with curl: curl --header "Content-Type: application/json" \ in zsh at 12:03:06
/// --request GET \
/// http://localhost:3000/organizations
pub async fn index(State(app_state): State<AppState>) -> impl IntoResponse {
let organizations = organization::Entity::find()
.all(&app_state.database_connection.unwrap())
Expand All @@ -27,6 +30,10 @@ impl OrganizationController {
}

/// CREATE a new Organization entity
/// Test this with curl: curl --header "Content-Type: application/json" \
/// --request POST \
/// --data '{"name":"My New Organization"}' \
/// http://localhost:3000/organizations
pub async fn create(State(app_state): State<AppState>, Json(organization_json): Json<organization::Model>) -> impl IntoResponse {
debug!("CREATE new Organization: {}", organization_json.name);

Expand All @@ -43,6 +50,9 @@ impl OrganizationController {
}

/// DELETE an Organization entity specified by its primary key
/// Test this with curl: curl --header "Content-Type: application/json" \ in zsh at 12:03:06
/// --request DELETE \
/// http://localhost:3000/organizations/<id>
pub async fn delete(State(app_state): State<AppState>, Path(id): Path<i32>) -> impl IntoResponse {
debug!("DELETE Organization by id: {}", id);

Expand Down

0 comments on commit 6dcac29

Please sign in to comment.