Skip to content

louis77/nova-http-client

Repository files navigation


HTTP Client extension for Nova

HTTP Client is an extension for the Nova editor to make HTTP calls from a *.http file.

Includes:

  • HTTP Syntax highlighting
  • Auto-completion for many HTTP Headers and their standard values
  • File and request-scoped variables
  • Run HTTP command
  • Run HTTP task
  • Sidebar with request history

HTTP Client tries to be compatible to the very popular REST Client extension of VS Code, however it supports only a small subset of its features, yet.

Getting Started

  1. Install the extension from the Nova extensions library.

  2. Create a file with "http" extension, or select the HTTP Language in the current editor

  3. Write a HTTP verb and URL in a line:

GET https://wikipedia.org
  1. Put the cursor on the line and press CMD-R or right-click and select the "Run HTTP" command

  2. HTTP Client will open a new editor with the result of the request (HTTP & body). It detects if the response is HTML, JSON or XML and selects the appropriate syntax in Nova.

(back to top)

Usage

In the editor, type an HTTP request by starting with a HTTP verb (all UPPERCASE):

GET https://postman-echo.com/get

Add request headers

GET https://postman-echo.com/get
x-api-key: test
x-version: 1.0

Some headers will be automatically added to the request, but you can overwrite them.

Add request body

Separate the body with an empty line after URL/headers:

POST https://postman-echo.com/post
Content-Type: application/json

{
  "name": "louis77"
}

You can also specify a file path to use as a body, which starts with <. It will try to read the file and use it as the body.

POST https://postman-echo.com/post
Content-Type: application/json

< /home/joe/payload.json

Multiple request blocks

Separate multiple request in the same file with ### on a separate line. You can also add some text to name your requests. If you just type s a Clip will popup.

Place the cursor anywhere inside a request when running it.

GET https://postman-echo.com/get
x-api-key: test
x-version: 1.0

### My request

POST https://postman-echo.com/post
Content-Type: application/json

{
  "name": "louis77"
}

Variables

HTTP Client support the definition and usage of file and request-scoped variables.

File variables are defined at the beginning of the file or inside a block (separated by ###) which does not contain a request.

Request-scoped variables are defined at the beginning of a request block.

@echoUrl = https://httpbin.org     <--- file variable

### GET anything

@method = get     <--- request-scoped variable

GET {{echoUrl}/@method

### another global block

@key = test    <--- file variable, available from this point on

### 

GET {{echoUrl}}/get
x-api-key: {{key}} 

In this example, echoUrl is a file variable which is available to all requests after it is defined. methodis a request-scoped variable which is only available in the request block it was defined.

Variable substitution with {{variable}} works for subsequent variable values, request URLs, and header values:

@baseURL = http://localhost:8080
@basePath = {{baseURL}}/api
@type = application/json

GET {{basePath}}
Content-Type: {{type}}

(back to top)

Execute HTTP requests

You have several options to execute the current HTTP request:

  1. Right-click and select "Run HTTP"
  2. Press CMD-R
  3. Bring up the command palette (CMD-SHIFT-P) and search for "Run HTTP"
  4. Click on the "Run HTTP Task" run button
  5. Use the menu "Editor > Run HTTP"

The cursor must always be anywhere inside an HTTP request.

(back to top)

History Sidebar

HTTP Client features a sidebar to list your request history:

Settings

This extension provides a few settings to customize its behaviour:

  • Follow Redirects (3xx responses) (default: true)
  • Specify a timeout for requests

(back to top)

Limitations

  • Non text-based responses (i.e. binary, images) are not supported yet

(back to top)

Roadmap

Let me know if you find the extension useful and what features you want to see.

  • Option to include request (w/o body) in response output
  • Look for a global "requests.http" to populate Task list
  • Open response document immediately and populate incrementally
  • Environment variables
  • Variables defined via settings
  • Run multiple requests at once

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Donate

If you like this extension and want it to get better over time, please consider showing your appreciation by donating a small tip. Thank you!

(back to top)

License

Distributed under the GPL-3-or-later. See LICENSE.txt for more information.

(back to top)

Contact

Louis Brauer - @BrauerLouis1 - [email protected]

Project Link: https://github.com/louis77/nova-http-client

(back to top)

About

Nova extension to make HTTP calls from a text file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published