A blazingly fast HTTP client with a magnificent request building syntax, made for humans.

Overview

🔗 glue

GitHub license PRs Welcome

Make requests, select JSON responses, nest them in other requests: A magnificent syntax for blazingly fast cli HTTP calls, made for humans.

Table of Contents

Getting started

Install & Update

At the moment, you can install or update glue for your system by building it from source. It has been done quite easy by the script install.sh.

All build dependencies (including Rust) will be deleted right after the installation automatically if Rust wasn't already on your system.

  1. Clone the repo
git clone https://github.com/mikesposito/glue
  1. Go to glue root directory
cd glue
  1. Add execute permission and run install.sh
chmod +x ./install.sh && ./install.sh

Usage

To start an interactive glue shell, simply run:

glue

alternatively, you can also execute a request directly:

glue <REQUEST>

The simplest request you can do with glue is using just the method and the url:

glue 'get https://dog.ceo/api/breeds/list/all'
# or in glue shell:
get https://dog.ceo/api/breeds/list/all

Syntax

Overview

The main gluescipt request syntax is the following:

[METHOD] [URL] [OPERATORS]

Methods available

Glue Keyword Description
get Executes a GET http call
post Executes a POST http call
patch Executes a PATCH http call
put Executes a PUT http call
delete Executes a DELETE http call
req Reuses a saved request response from memory

Operators available

Operators allow to execute operations on requests (body, headers params, nesting), on responses (selectors, variables)

Operation Syntax Example
JSON Result Selector ^selector ^$.message
Body attribute ~key=value ~username=admin
Body attribute quoted ~key="value" ~fullname="John Doe"
Raw JSON body ~#-json-# ~#-{"username": "admin"}-#
Header attribute *key=value *authorization=xxx
Header attribute quoted *key="value" *authorization="Bearer xxx"
Nested request { nested_request } get api.com/users/{get api.com/me}
Save response in var >var >login_request
Sequential request separator request; other_request req test1; req test2

JSON result selector

If the response is of type JSON, you can add a jsonpath selector to the request with the char ^. Glue will only return the desired value from the response. This applies also for Nested requests.

get https://dog.ceo/api/breeds/list/all^$.message.terrier

# OUTPUT:
# > [GET] https://dog.ceo/api/breeds/list/all
# 
# 
# [
#   [
#     "american",
#     "australian",
#     "bedlington",
#     "border",
#     "cairn",
#     "dandie",
#     "fox",
#     "irish",
#     "kerryblue",
#     "lakeland",
#     "norfolk",
#     "norwich",
#     "patterdale",
#     "russell",
#     "scottish",
#     "sealyham",
#     "silky",
#     "tibetan",
#     "toy",
#     "welsh",
#     "westhighland",
#     "wheaten",
#     "yorkshire"
#   ]
# ]

Body attributes

You can use the char ~ to add body attributes to the request:

post https://example.com/user/add ~username=admin
# or
post https://example.com/user/add~username=admin

# glue will send a body of type JSON 
# with a key "username" with value "admin"

Raw JSON Body

Raw JSON values can also be used between ~#-JSON- instead of single attributes:

post https://example.com/users ~#-{ "name": "John" }-#
# or 
post https://example.com/users~#-{ "name": "John" }-#

Note

Body attributes can take their value from another request's response by using nested requests feature.

Headers

You can use the char * to set headers to the request:

post https://example.com/user/add*authorization=6a75d4d7-84c3
# or
post https://example.com/user/add *authorization=6a75d4d7-84c3

# glue will set Authorization header
# to value "6a75d4d7-84c3"

Quotes can also be use to escape special glue chars or spaces in attributes:

post https://example.com/user/add*authorization="Bearer 6a75d4d7-84c3"

Note

Headers can take their value from another request's response by using nested requests feature.

Nested requests

One of the most useful features of glue is the request nesting.

You can reuse response values (total or partial) from a request to build another request.

Glue supports infinite nesting and will build a dependency tree, divide it in layers and execute each layer on parallel for the maximum time optimization.

You can use request nesting delimiting the desired nested request with {}:

get api.com/users/{ get api.com/me^$.user.id }/

# glue will execute this two requests:

# 1. api.com/me - and will select user.id from the response (eg. 12345)

# 2. api.com/users/12345/

Request can also be nested inside body or headers parameters:

get api.com/me *authorization={get api.com/login^$.access_token}/

Run file

You can also create a file with request to run, and pass the file path to glue with flag -f to execute it. You can try with one of the sample requests in examples folder:

glue -f examples/sample-request.glue

Multiple requests

Files can also contain multiple sequential requests separated by ;. Take a look at ./examples/sequential-requests.glue.

Save response in variable

You can save a request response in a temporary variable with a name of your choice with the char >, to reuse it without executing the call again.

get https://dog.ceo/api/breeds/list/all >test_req

to use the saved response:

req test_req

You can also use a selector on the saved response with ^:

req test_req^$.message.terrier

Note: Variables are available only in the same glueshell session and dropped at the end of it.

Contributing

The main purpose of this repository is to continue evolving glue core, making it faster and easier to use. Development of glue happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving glue.

Code of Conduct

glue has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Contributing Guide

Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to glue.

Good First Issues

To help you get your feet wet and get you familiar with our contribution process, we have a list of good first issues that contain bugs which have a relatively limited scope. This is a great place to get started.

License

glue is MIT licensed.

You might also like...
Thalo is an event-sourcing framework for building large scale systems
Thalo is an event-sourcing framework for building large scale systems

Thalo Event sourcing framework for building microservices. Overview Thalo is an event-sourcing framework for building large scale systems based on the

HTTP Proxy based solution for real-time interception and prioritization of SQL queries.
HTTP Proxy based solution for real-time interception and prioritization of SQL queries.

starproxy ⚠️ starproxy is a prototype: Not currently used in production, but will likely be some day. Table of Contents starproxy Table of Contents Ba

Rust HTTP API Template using PostgreSQL, Redis, RabbitMQ, and Hexagonal Architecture

Rust Template HTTP API Rust API Template using PostgreSQL, Redis, RabbitMQ, and Hexagonal Architecture The following template provides a basic structu

An async no_std HTTP server suitable for bare-metal environments, heavily inspired by axum

picoserve An async no_std HTTP server suitable for bare-metal environments, heavily inspired by axum. It was designed with embassy on the Raspberry Pi

WIP: A Rust client for caniuse.com
WIP: A Rust client for caniuse.com

caniuse-rs A Rust client for caniuse.com. It pulls data from caniuse.com and caches it locally, in a transformed JSON structure that is easier to reas

Open Source command line client of VRChat Package Manager.

vrc-get Open Source command line client of VRChat Package Manager. Goals Provide Open Source command line client of VRChat Package Manager. Provide mo

Rust/Axum server implementation with PCR(Prisma Client Rust)
Rust/Axum server implementation with PCR(Prisma Client Rust)

Realworld Rust Axum Prisma This project utilizes Rust with the Axum v0.7 framework along with the Prisma Client Rust to build a realworld application.

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

A fast static site generator in a single binary with everything built-in. https://www.getzola.org

zola (né Gutenberg) A fast static site generator in a single binary with everything built-in. Documentation is available on its site or in the docs/co

Comments
  • fix: json selection value check before unwrapping

    fix: json selection value check before unwrapping

    Description

    When glue needs just a single selected value instead of an array of selections, we have to be sure that the selection array is not empty before selecting the first value.

    Types of changes

    • [x] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)

    Checklist:

    • [x] My code follows the code style of this project.
    • [ ] My change requires a change to the documentation.
    • [ ] I have updated the documentation accordingly.
    • [ ] I have added tests to cover my changes.
    • [x] All new and existing tests passed.
    opened by mikesposito 0
  • Shell interactive mode doesn't handle prompt properly

    Shell interactive mode doesn't handle prompt properly

    Describe the bug At the moment, Glueshell seems to not handle user input properly. All arrows and common combination (eg. Ctrl + Arrow) doesn't work.

    To Reproduce Steps to reproduce the behavior:

    1. Start glue on interactive mode
    2. Use arrows to navigate
    3. See arrows don't work
    bug good first issue 
    opened by mikesposito 0
Releases(v0.1.0)
Owner
Michele Esposito
Senior Software Engineer @ConsenSys
Michele Esposito
⚡ A Blazingly-Fast Static Site Generator, built with Rust.

Stuart A Blazingly-Fast Static Site Generator. Download Now » Stuart is a very fast and flexible static site generator, with build times as low as 0.1

William Henderson 5 Nov 25, 2022
A secure and efficient gateway for interacting with OpenAI's API, featuring load balancing, user request handling without individual API keys, and global access control.

OpenAI Hub OpenAI Hub is a comprehensive and robust tool designed to streamline and enhance your interaction with OpenAI's API. It features an innovat

Akase Cho 30 Jun 16, 2023
Htmx extractors and request guards for axum.

axum-htmx axum-htmx is a small extension library providing extractors and request guards for the various htmx headers within axum. Additionally, the l

Rob 5 Aug 14, 2023
Rust / Wasm framework for building client web apps

Yew Rust / Wasm client web app framework Documentation (stable) | Documentation (latest) | Examples | Changelog | Roadmap | 简体中文文档 | 繁體中文文檔 | ドキュメント A

Yew Stack 25.8k Jan 2, 2023
Axum + JWT authentication Middleware that allows you to start building your application fast

axum_jwt_ware Integration Guide Simple Axum + JWT authentication middleware with implemented Login and refresh token. Goal I aim to simplify the proce

Eze Sunday 3 Dec 2, 2023
Sōzu HTTP reverse proxy, configurable at runtime, fast and safe, built in Rust. It is awesome! Ping us on gitter to know more

Sōzu · Sōzu is a lightweight, fast, always-up reverse proxy server. Why use Sōzu? Hot configurable: Sozu can receive configuration changes at runtime

sōzu 2k Dec 30, 2022
A html document syntax and operation library written in Rust, use APIs similar to jQuery.

Visdom A server-side html document syntax and operation library written in Rust, it uses apis similar to jQuery, left off the parts thoes only worked

轩子 80 Dec 21, 2022
lispr is a Rust macro that tries to implement a small subset of LISPs syntax in Rust

lispr lispr is a Rust macro that tries to implement a small subset of LISPs syntax in Rust. It is neither especially beautiful or efficient since it i

Jan Vaorin 0 Feb 4, 2022
Sauron is an html web framework for building web-apps. It is heavily inspired by elm.

sauron Guide Sauron is an web framework for creating fast and interactive client side web application, as well as server-side rendering for back-end w

Jovansonlee Cesar 1.7k Dec 26, 2022
🌱🦀🌱 Trillium is a composable toolkit for building web applications with async rust 🌱🦀🌱

?????? Trillium is a composable toolkit for building web applications with async rust ??????

Trillium 243 Jan 2, 2023