app rede

CLI tool to run and configure suites of HTTP requests defined in readable files

3 unstable releases

0.2.0 Oct 7, 2024
0.1.1 Apr 14, 2024
0.1.0 Apr 13, 2024

#132 in HTTP client

Download history 5/week @ 2024-09-18 6/week @ 2024-09-25 140/week @ 2024-10-02 49/week @ 2024-10-09 3/week @ 2024-10-16

85 downloads per month

Apache-2.0 OR MIT

99KB
2K SLoC

Rede

Rust CI Crates.io Version

rede (galician word for "net") is a command-line utility to help run suites of requests to ease the usage and testing of REST APIs. The main inspiration for this project comes from Bruno and their command line tool.

The main goal behind this project is to have a suite of text files representing HTTP requests that will be picked and executed by rede, allowing for easy sharing and control versioning of these requests.

Execution of rede

The --verbose looks good too:

How verbose looks

Installation

As this still an early stage of the project the only way of installing it is using cargo, so you would need to have Rust installed and run:

cargo install rede

How to run

rede works using a DSL of TOML schemas. All the documentation regarding rede DSL is still under development, but a request to get a couple of good boy facts would look like this:

[http]
method = "GET"
url = "https://dogapi.dog/api/v2/facts"

[headers]
Accept = "application/json"
User-Agent = "rede/v0.1.0"

[query_params]
limit = 2

You can generate this same request executing the rede example command. Then, once you have a valid request like the one generated by the example you only need to run it with rede:

rede run <your_file>

What's next

rede is still in the early stage of its development. The following versions should make it capable of an execution like the following one.

Imagine the following file ./request.toml in your project.

[http]
method = "POST"
url = "{{host}}/v1/movies"

[metadata]
name = "Add new movie"
api_version = "v1"

[input_params]
title = "string"

[input_params.release_date]
type = "string"
hint = 'Release date in format "YYYY-MM-DD"'
default = '{{utils.today("YYYY-MM-DD")}}'

[headers]
Content-Type = "application/json"
Authorization = "Bearer {{token}}"

body.json = '''
{
  "title": {{title}},
  "release_date": {{release_date}},
  "debug": true
}
'''

And imagine that you also have a ./env/local.toml file like this:

host = "http://localhost:8080"
token = "MyPersonalToken"

Then from your project you could run rede and this would happen:

$ rede run --env local request
  Running request "Add new movie"
  Please, insert: `title` (string):
$ The Lion King
  Please, insert: Release date in format "YYYY-MM-DD"
  Send empty line to use default: "2024-02-29"
$ 1994-10-07

  >> HTTP Request >>
  POST localhost:8080/v1/movies
  HTTP/2.0
    - Content-Type: application/json
    - Authorization: Bearer MyPersonalToken

  [application/json]
  { "title": "The Lion King", "release_date": "1994-10-07", "debug": true }

  << HTTP Response <<
  201 Created
  HTTP/2.0
    - Content-Type application/json

  { "id": 1, "title": "The Lion King", "release_date": "1994-10-07" }

This is the idea behind rede, creating parametrizable and reusable request in TOML format that can be used from the command line to test you APIs. But there's still a long road ahead before this is the reality.

Dependencies

~17–33MB
~454K SLoC