Code Monkey home page Code Monkey logo

burl's Introduction

Better curl(1)

burl(1) is a tiny shell script augmenting curl(1) with some helpful shortcuts.

$ POST '{"title":"better curl(1)"}' /todo/item

Installation

$ make install

Optional hostname

By default burl(1) will assume "http://localhost:3000", however you can alter this default by exporting BURL in your terminal session or .profile:

$ export BURL=http://site-im-testing.com
$ burl /pathname

Or like usual you can specify a full url:

$ burl http://google.com

-j, --json DATA

POST data as "Content-Type: application/json":

$ burl -j {"name":"tobi"} /user

HTTP verbs

Instead of the typical -X DELETE verb usage with curl(1), you may use the verbs directly, for example:

$ burl PATCH -d '[email protected]' /user/12
$ burl DELETE /users

JSON request bodies

Usually when you want to request with some JSON you do something like:

$ curl -X PATCH -d '{"name":"tobi"}' -H "Content-Type: application/json" http://localhost:3000/user/12

With burl(1) you can simply add a JSON array or object after the HTTP verb:

$ burl PATCH '{"name":"tobi"}' /user/12
$ burl POST [1,2,3] /numbers

JSON requests from files

To issue a request with the contents of ./some.json, instead of writing:

$ curl --data @some.json -H "Content-Type: application/json" http://localhost:3000/

Simply invoke:

$ POST @some.json /

Expressive header fields

With burl(1) you can define header fields without -H:

$ burl If-None-Match: etag /users
$ burl If-None-Match: etag Accept: application/json /users

Accept shorthand

Currently .json, .text and .html shorthands are available and set the Accept header field for you:

$ burl /users
$ burl /users .json
$ burl /users .text
$ burl /users .html

Extras

  • Added support for prettyjson. It needs python and json.tool module.

Aliases

Try these aliases if you want to get fancy:

alias GET='burl GET'
alias HEAD='burl -I'
alias POST='burl POST'
alias PUT='burl PUT'
alias PATCH='burl PATCH'
alias DELETE='burl DELETE'
alias OPTIONS='burl OPTIONS'

burl's People

Contributors

tj avatar fizerkhan avatar jothirams avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.