create account

Building a REST API in Rust (Part 3) by tensor

View this thread on: hive.blogpeakd.comecency.com
· @tensor · (edited)
$42.63
Building a REST API in Rust (Part 3)
#### What Will I Learn?

- You will learn how to build routes using declarative macros with Rust's Rocket library
- You will learn how to build and consume JSON structures in Rust
- You will learn how to query JSON through HTTP methods and routes using Postman

#### Requirements

- A moderate understanding of the Rust programming language
- A basic understanding of JavaScript Object Notation *(JSON)*
- A basic understanding of Hypertext Transfer Protocol *(HTTP)*
- A moderate understanding of what Macros are in programming

#### Difficulty

- Intermediate


#### Description
In this video, we finish the Rust side of our **API project**.  We use various **declarative macros** to build the routes that we need to produce and consume **JSON**.  We also use a JSON macro to format the JSON in our application properly.  We connect our Database pool and our Routes so that we can convert the JSON into data that our database can read.  We also serve our database data as JSON on our API endpoints.  We also briefly look at how we can catch different patterns using the **Rocket Catcher! macro** which allows us to catch basic HTTP errors such as *404 resource not found*.  This ground work will allow us to move forward and build a *front-end* using the **Elm programming language**. 

The source code for this project can be found [here](https://github.com/tensor-programming/rust_api_part_3)

#### Video Tutorial
<iframe width="560" height="315" src="https://www.youtube.com/embed/GKXCLc8F7nA" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

#### Curriculum

- [Building a REST API in Rust (Part 1)](https://utopian.io/u/25955343)
- [Building a REST API in Rust (Part 2)](https://utopian.io/u/26156255)

    

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@tensor/building-a-rest-api-in-rust-part-3">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authortensor
permlinkbuilding-a-rest-api-in-rust-part-3
categoryutopian-io
json_metadata{"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":724712,"name":"rust","full_name":"rust-lang/rust","html_url":"https://github.com/rust-lang/rust","fork":false,"owner":{"login":"rust-lang"}},"pullRequests":[],"platform":"github","type":"video-tutorials","tags":["utopian-io","steemstem","steemiteducation","programming","technology"],"links":["https://github.com/tensor-programming/rust_api_part_3","https://utopian.io/u/25955343","https://utopian.io/u/26156255"],"moderator":{"account":"ewq","time":"2018-01-18T14:37:12.264Z","reviewed":true,"pending":false,"flagged":false}}
created2018-01-18 02:46:06
last_update2018-01-18 14:37:12
depth0
children4
last_payout2018-01-25 02:46:06
cashout_time1969-12-31 23:59:59
total_payout_value29.914 HBD
curator_payout_value12.713 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,915
author_reputation87,856,203,149,624
root_title"Building a REST API in Rust (Part 3)"
beneficiaries
0.
accountutopian.pay
weight2,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,302,195
net_rshares6,357,905,545,058
author_curate_reward""
vote details (50)
@ewq ·
$1.67
Thank you for the contribution. It has been approved.

You can contact us on [Discord](https://discord.gg/uTyJkNm).
**[[utopian-moderator]](https://utopian.io/moderators)**
👍  ,
properties (23)
authorewq
permlinkre-tensor-building-a-rest-api-in-rust-part-3-20180118t143717084z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-18 14:37:18
last_update2018-01-18 14:37:18
depth1
children2
last_payout2018-01-25 14:37:18
cashout_time1969-12-31 23:59:59
total_payout_value1.255 HBD
curator_payout_value0.412 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length172
author_reputation2,798,579,990,254
root_title"Building a REST API in Rust (Part 3)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,408,361
net_rshares201,335,340,220
author_curate_reward""
vote details (2)
@tensor ·
As always, thank you for watching my content.
properties (22)
authortensor
permlinkre-ewq-re-tensor-building-a-rest-api-in-rust-part-3-20180118t173129995z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-18 17:31:27
last_update2018-01-18 17:31:27
depth2
children0
last_payout2018-01-25 17:31:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length45
author_reputation87,856,203,149,624
root_title"Building a REST API in Rust (Part 3)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,442,761
net_rshares0
@utopian.tip ·
Hey @ewq, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
👍  
properties (23)
authorutopian.tip
permlinkre-re-tensor-building-a-rest-api-in-rust-part-3-20180118t143717084z-20180118t165433
categoryutopian-io
json_metadata""
created2018-01-18 16:54:33
last_update2018-01-18 16:54:33
depth2
children0
last_payout2018-01-25 16:54:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length153
author_reputation238,310,597,885
root_title"Building a REST API in Rust (Part 3)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,435,552
net_rshares0
author_curate_reward""
vote details (1)
@utopian-io ·
### Hey @tensor I am @utopian-io. I have just upvoted you!
#### Achievements
- You have less than 500 followers. Just gave you a gift to help you succeed!
- Seems like you contribute quite often. AMAZING!
#### Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER!
- <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a>
- <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a>
- Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a>

[![mooncryption-utopian-witness-gif](https://steemitimages.com/DQmYPUuQRptAqNBCQRwQjKWAqWU3zJkL3RXVUtEKVury8up/mooncryption-s-utopian-io-witness-gif.gif)](https://steemit.com/~witnesses)

**Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
properties (22)
authorutopian-io
permlinkre-tensor-building-a-rest-api-in-rust-part-3-20180118t150809566z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-18 15:08:09
last_update2018-01-18 15:08:09
depth1
children0
last_payout2018-01-25 15:08:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,082
author_reputation152,955,367,999,756
root_title"Building a REST API in Rust (Part 3)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id30,414,799
net_rshares0