Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Configure Rust functions (#430)
* Add ability to add all custom function configuration in a separate module. Co-authored-by: Dejan Bosanac <dejan@sensatic.net> Co-authored-by: Jim Crossley <jcrossley3@gmail.com> Co-authored-by: Jim Crossley <jcrossley3@gmail.com>
- Loading branch information
Showing
8 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
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
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
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,26 @@ | ||
use actix_web::web; | ||
|
||
/// Run custom configuration as part of the application building | ||
/// process. | ||
/// | ||
/// This function should contain all custom configuration for your function application. | ||
/// | ||
/// ```rust | ||
/// fn configure(cfg: &mut web::ServiceConfig) { | ||
/// let db_driver = my_db(); | ||
/// cfg.data(db_driver.clone()); | ||
/// } | ||
/// ``` | ||
/// | ||
/// Then you can use configured resources in your function. | ||
/// | ||
/// ```rust | ||
/// pub async fn handle( | ||
/// event: Event, | ||
/// driver: web::Data<DbDriver>, | ||
/// ) -> Result<Event, actix_web::Error> { | ||
/// Ok(Event::default()) | ||
/// } | ||
pub fn configure(_cfg: &mut web::ServiceConfig) { | ||
log::info!("Configuring service"); | ||
} |
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
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
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,26 @@ | ||
use actix_web::web; | ||
|
||
/// Run custom configuration as part of the application building | ||
/// process. | ||
/// | ||
/// This function should contain all custom configuration for your function application. | ||
/// | ||
/// ```rust | ||
/// fn configure(cfg: &mut web::ServiceConfig) { | ||
/// let db_driver = my_db(); | ||
/// cfg.data(db_driver.clone()); | ||
/// } | ||
/// ``` | ||
/// | ||
/// Then you can use configured resources in your function. | ||
/// | ||
/// ```rust | ||
/// pub async fn index( | ||
/// req: HttpRequest, | ||
/// driver: web::Data<DbDriver>, | ||
/// ) -> HttpResponse { | ||
/// HttpResponse::NoContent() | ||
/// } | ||
pub fn configure(_cfg: &mut web::ServiceConfig) { | ||
log::info!("Configuring service"); | ||
} |
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