demo-api

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

README

demo-api

A simple command-line JSON server. If you need to stub out an API locally, this is the tool you need. It's lightweight, works on Mac, Windows, and Linux, and requires no setup.

Create a JSON file called data.json:

{
  "notes" : [
    {
      "id" : 1,
      "title" : "Hello World"
    },
    {
      "id" : 2,
      "title" : "The second note"
    }
  ]
}

Then run demo-api.

Visit http://localhost:8080 in the browser to see the file served as JSON.

In addition, since the JSON file is structured like a typical REST API data structure, the following will work:

  • GET http://localhost:8080/notes - retrive all "notes"
  • GET http://localhost:8080/notes/1 - retrive the note with the id of 1
  • POST http://localhost:8080/notes/ - Create a new note. This modifies the data.json file.
  • DELETE http://localhost:8080/notes/1 - Delete the note with the id of 1. This modifies the data.json file.

Installation

To install, download the latest release to your system and copy the executable to a location on your path. Then launch it in a directory containing data.json.

Roadmap

  • PUT/PATCH support
  • tests
  • refactoring
  • help switch
  • version notice

Contributing

Please contribute. Fork, create a PR.

License

Apache 2. See LICENSE file.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL