Creating a microservice

Create a new binary crate and add the following dependencies:

failure = "0.1"
futures = "0.1"
gotham = "0.3"
gotham_derive = "0.3"
hyper = "0.12"
mime = "0.3"
tokio = "0.1"
tokio-postgres = { git = "https://github.com/sfackler/rust-postgres" }

As you can see, we added the gotham and gotham_derive crates. The first is a framework and the second helps us derive an implementation of the StateData trait for the shared state with the connection we need. The gotham_derive crate can also be used to derive the NewMiddleware trait for middleware, but we don't need special middleware for our example.

We also added the tokio-postgres crate to dependencies. It contains an implementation of an asynchronous database connector for PostgreSQL.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.237.29