#3: Conspiracies, Dissemination, and REST APIs

While you were away

Creating a Web Service

A simple HTTP GET Request

Adding Middleware

Running `target/debug/conspiracies_api`
INFO 2018-06-06T21:43:40Z: actix_web::server::srv: Starting 8 http workers
INFO 2018-06-06T21:43:40Z: actix_web::server::srv: Starting server on
Started http server:
INFO 2018-06-06T21:43:46Z: actix_web::middleware::logger: [06/Jun/2018:17:43:46 -0400] "GET /tags HTTP/1.1" 200 240 "-" "insomnia/5.16.6" 0.001722

Actors & Messages

  • Send a message to other actors
  • Do work based on the message it receives
  • Start other actors

The GET /conspiracies/{page_id} route

Meanwhile, Back in the Route Handler

Starting the actix::System

The GET /conspiracies route

let page_num = req.query()

req.state().db.send(Conspiracies{page_num: page_num})

Handling HTTP Posts

#[derive(Insertable, Debug, Serialize, Deserialize)]
pub struct NewTag {
pub name: String
--> src/conspiracies_api/main.rs:34:37
34 | req.state().db.send(AddTag{tag: tag})
| ^^^ expected struct `conspiracies::models::NewTag`, found struct `actix_web::Json`




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Configuring Carrierwave with AWS S3 on your Rails Application + Figaro

Migrating a Digital Ocean LoadBalancer to another Kubernetes cluster

How to manage Helpdesk with a shared inbox

Life in a Relational World

Engineering: Computer Science: What is in it? Is it good to choose as your career?

Automate tagging to EBS volumes using AWS Lambda and CloudWatch

Winning Hackon with Amazon

Hyperledger Fabric Tools — 2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rob Rowe

Rob Rowe

More from Medium

Object Oriented Programming in C++ 101 (A practical Approach)

Scoped lock c++

Dynamic Library In C

Factory Pattern