10 Building an HTTP REST API CLI

This chapter covers

  • Deciding which tools and libraries to use
  • Designing the CLI
  • Declaring the commands
  • Implementing the commands
  • Implementing requests
  • Handling errors gracefully
  • Testing our CLI

Continuing the work we did in the previous chapter, we’ll write a CLI tool for the API service we wrote. Using a CLI tool, we’ll demonstrate another way to interact asynchronously in Rust by making HTTP requests with a separate service (which we also wrote). Our CLI tool will provide a convenient way to interact with our todo app backend (the API service). We’ll use Rust’s async features to showcase the basics of writing async Rust from the client side of a client-server relationship.

Writing CLI tools is one way to ...

Get Code Like a Pro in Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.