Giter VIP home page Giter VIP logo

http-gonsole's Introduction

http-gonsole

This is the Go port of the http-console.

Speak HTTP like a local

Talking to an HTTP server with curl can be fun, but most of the time it's a PITA.

http-gonsole is a simple and intuitive interface for speaking the HTTP protocol.

PS: HTTP has never been this much fun.

Prerequisite

You'll need the to install go, http-gonsole is tested with release.r57.1.

How to use

Let's assume we have a CouchDB instance running locally.

connecting

To connect, we run http-gonsole, passing it the server host and port as such:

$ http-gonsole 127.0.0.1:5984 

navigating

Once connected, we should see the http prompt:

http://127.0.0.1:5984/>

server navigation is similar to directory navigation, except a little simpler:

http://127.0.0.1:5984/> /logs
http://127.0.0.1:5984/logs> /46
http://127.0.0.1:5984/logs/46> ..
http://127.0.0.1:5984/logs> ..
http://127.0.0.1:5984/>

requesting

HTTP requests are issued with the HTTP verbs GET, PUT, POST, HEAD and DELETE, and a relative path:

http://127.0.0.1:5984/> GET /
HTTP/1.1 200 OK
Date: Mon, 31 May 2010 04:43:39 GMT
Content-Length: 41

{
    couchdb: "Welcome",
    version: "0.11.0"
}

http://127.0.0.1:5984/> GET /bob
HTTP/1.1 404 Not Found
Date: Mon, 31 May 2010 04:45:32 GMT
Content-Length: 44

{
    error: "not_found",
    reason: "no_db_file"
}

When issuing POST and PUT commands, we have the opportunity to send data too:

http://127.0.0.1:5984/> /rabbits
http://127.0.0.1:5984/rabbits> POST
... {"name":"Roger"}

HTTP/1.1 201 Created
Location: http://127.0.0.1/rabbits/2fd9db055885e6982462a10e54003127
Date: Mon, 31 May 2010 05:09:15 GMT
Content-Length: 95

{
    ok: true,
    id: "2fd9db055885e6982462a10e54003127",
    rev: "1-0c3db91854f26486d1c3922f1a651d86"
}

Make sure you have your Content-Type header set properly, if the API requires it. More in the section below.

Note that if you're trying to POST to a form handler, you'll most probably want to send data in multipart/form-data format, such as name=roger&hair=black. http-gonsole sends your POST/PUT data as is, so make sure you've got the format right, and the appropriate Content-Type header.

setting headers

Sometimes, it's useful to set HTTP headers:

http://127.0.0.1:5984/> Accept: application/json
http://127.0.0.1:5984/> X-Lodge: black

These headers are sent with all requests in this session. To see all active headers, run the \headers or \h command:

http://127.0.0.1:5984/> \headers
Accept: application/json
X-Lodge: black

Removing headers is just as easy:

http://127.0.0.1:5984/> Accept:
http://127.0.0.1:5984/> \h
X-Lodge: black

cookies

You can enable cookie tracking with the --cookies option flag. To see what cookies are stored, use the \cookies or \c command.

SSL

To enable SSL, pass the --ssl flag, or specify the address with https.

quitting

http://127.0.0.1:5984/> \q

or,

http://127.0.0.1:5984/> ^D

nuff' said.

License

BSD License

http-gonsole's People

Contributors

aht avatar mattn avatar

Watchers

 avatar  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.