Giter Site home page Giter Site logo

httpu's Introduction

httpu

httpu

httpu is a terminal first, general purpose HTTP client, designed to get you interacting with all aspects of an HTTP API within just a few seconds. This makes it a good tool for testing out various endpoints, methods, payloads - so you are able to see what's being sent, and what response you are then getting.

Getting started

Installing

macOS

brew tap httpu/httpu
brew install httpu

Building from source

cd $GOPATH
mkdir -p src/github.com/hazbo
cd src/github.com/hazbo
git clone [email protected]:hazbo/httpu.git
cd httpu
make

Basic usage

I started writing this project whilst working with the Moltin API, which is a headless commerce API, so there are a few examples using that, if you want to play around with that, just head to the website, get your API keys and you are good to go!

Once httpu has been installed, you can get started either by first pulling down the preconfigured packages:

httpu pull

And then loading the configuration of a package into httpu like so:

httpu new moltin

or by creating your own configuration. A basic project may look like the following:

mkdir -p httpbin/requests
touch httpbin/project.json httpbin/requests/ip.json

httpbin/project.json

{
  "project": {
    "url": "https://nghttp2.org/httpbin",
    "resourceFiles": [
      "httpbin/requests/ip.json"
    ]
  }
}

httpbin/requests/ip.json

{
  "kind": "request",
  "name": "ip",
  "spec": {
    "uri": "/ip",
    "method": "GET"
  }
}

Once you have that setup, you're ready to run httpu!

httpu new httpbin

When the UI has loaded, typing in ip (the name of the request) into the prompt, followed by hitting enter will run that request and you will be able to see the response body in the right-hand window. In this case, it will simply just return your IP address from which the request has been made.

Keybinding Description
Up Switch to command mode
Down Switch to default mode
Left Move cursor to request view
Right Move cursor to response view
Ctrl+w Move cursor from request / response view to the prompt
Ctrl+s Switch the cursor from request view to response view
Ctrl+c Quit

To see what commands are available, switch to command mode, then type in list-commands.

Advanced usage

httpu is able to look at a JSON response, take a given value and store it in memory, to then be used for another request. This in-memory store is called the stash. So for example, in the previous example, if you wanted to store the IP address that is returned, and use it else where, the request file may look like this:

httpbin/requests/ip.json

{
  "kind": "request",
  "name": "ip",
  "spec": {
    "uri": "/ip",
    "method": "GET",
    "stashValues": [
      {
        "name": "my-ip",
        "jsonPath": "origin"
      }
    ]
  }
}

and then in a seperate request you can then access it, once the ip request has been made, like so:

httpbin/requests/get.json

{
  "kind": "request",
  "name": "get",
  "spec": {
    "uri": "/get?ip=${stash[ip]}",
    "method": "GET"
  }
}

with ${stash[ip]} being a variable created after running the ip request.

For more examples for advanced usage including the stash, sending request data, using environment variables etc... head over to the packages repo and check out the example I've started creating for the Moltin API.

Coming soon

  • A view to display response headers (priority)
  • Creating a request flow
  • Creating tests for a request or set of requests
  • Various UI tweaks
  • An HTTP API interface

Known issues

This project is in its very early stages, so there will be things that need fixing. One issue at the moment is a problem with parsing stashed variables into request data before a request has been made. If this happens, and you are seeing ${stash[var_name]}, just fire the request again and it should work.

Contributing

  • Fork httpu
  • Create a new branch (git checkout -b my-feature)
  • Commit your changes (git commit)
  • Push to your new branch (git push origin my-feature)
  • Create new pull request

httpu's People

Contributors

advancedhacker101 avatar rumyantseva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

httpu's Issues

Can't rebuild packages

Hi!
I cloned, the project, it works, but when I modify the code in for ex. cmd/httpu/commands/new.go
then do make build after that, it seems like nothing has changed!!
I also tried a lot of other things including make clean && make build make install go install ./...
but none of the above did the trick.
However when changing code in cmd/httpu/main.go, then building the project works.
My go version output go version go1.10 linux/amd64

"panic: runtime error: index out of range" when running httpu new

$ build/httpu new
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/hazbo/httpu/cmd/httpu/commands.newValue(0xc42000c060, 0x0, 0x0, 0x9f2d5801, 0xb36abab0961a5fa6)
	/Users/vania/go/src/github.com/hazbo/httpu/cmd/httpu/commands/new.go:24 +0x1d9
github.com/hazbo/httpu/cmd/httpu/commands.glob..func2(0xc42000c060, 0x0, 0x0, 0xc4200991e8, 0x1008cad)
	/Users/vania/go/src/github.com/hazbo/httpu/cmd/httpu/commands/new.go:58 +0x3f
github.com/hazbo/httpu/cmd/httpu/commands.(*Command).Run(0x1472c50, 0xc42000c060, 0x0, 0x0, 0xc420099268, 0xc42001e001)
	/Users/vania/go/src/github.com/hazbo/httpu/cmd/httpu/commands/commands.go:12 +0x48
main.main()
	/Users/vania/go/src/github.com/hazbo/httpu/cmd/httpu/main.go:60 +0xee

There is a bug at cmd/httpu/commands/new.go#L24. I suggest modifying that block to check for the existence of args, and if there isn't one printing a help message.

newFlagSet.Parse(args)
if len(args) == 0 {
	newFlagSet.Usage() // Print proper usage. Or use fmt.Printf()
    os.Exit(1)
}

More documentation / examples / tutorials

In the current README, so far I've gone over the very basics. Not all features have been covered, and there is little talk about httpu packages. Maybe some wiki pages, and some more details on the README would be helpful. Also a much better example video / gif is needed, the one I made is pretty bad.

Index out of range while trying to run with envvar

When I tried to set the environment variable NAME to foo and ran httpu, I noticed a index out of range panic.

It seems to me that whenever the length of NAME is lesser than the length of $env{[NAME]}, this issue happens.

Here's the stack trace

$ NAME=foo ./main new httpbin
panic: runtime error: index out of range

goroutine 1 [running]:
panic
        ../../../libgo/go/runtime/panic.go:557
runtime_panicstring
        ../../../libgo/runtime/panic.c:38
github_com_hazbo_httpu_vendor_github_com_hazbo_httpu_utils_varparser.VarParser.Parse
        go/src/github.com/hazbo/httpu/vendor/github.com/hazbo/httpu/utils/varparser/varparser.go:43
github_com_hazbo_httpu_vendor_github_com_hazbo_httpu_env.Parse
        go/src/github.com/hazbo/httpu/vendor/github.com/hazbo/httpu/env/env.go:24
github_com_hazbo_httpu_vendor_github_com_hazbo_httpu_resource_request.RequestSpec.parseEnvVars
        go/src/github.com/hazbo/httpu/vendor/github.com/hazbo/httpu/resource/request/modifier.go:40
github_com_hazbo_httpu_vendor_github_com_hazbo_httpu_resource_request.RequestSpec.Update
        go/src/github.com/hazbo/httpu/vendor/github.com/hazbo/httpu/resource/request/modifier.go:15
github_com_hazbo_httpu_vendor_github_com_hazbo_httpu_resource.FilePath.Load
        go/src/github.com/hazbo/httpu/vendor/github.com/hazbo/httpu/resource/resource.go:122
github_com_hazbo_httpu_vendor_github_com_hazbo_httpu.ConfigureFromFile
        go/src/github.com/hazbo/httpu/vendor/github.com/hazbo/httpu/configure.go:76
commands.newValue
        go/src/github.com/hazbo/httpu/vendor/github.com/hazbo/httpu/cmd/httpu/commands/new.go:41
commands.func2
        go/src/github.com/hazbo/httpu/vendor/github.com/hazbo/httpu/cmd/httpu/commands/new.go:58
github_com_hazbo_httpu_vendor_github_com_hazbo_httpu_cmd_httpu_commands.Command.Run
        go/src/github.com/hazbo/httpu/vendor/github.com/hazbo/httpu/cmd/httpu/commands/commands.go:12
main.main
        go/src/github.com/hazbo/httpu/cmd/httpu/main.go:60

openapi support

it would be great to see the client natively support openapi json/yaml, so rest apis that are already documented can be accessed more easily.

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.