Skip to content

Latest commit

 

History

History
44 lines (37 loc) · 793 Bytes

README.md

File metadata and controls

44 lines (37 loc) · 793 Bytes

Getting started

Clone the repository:

git clone [email protected]:AmirRezaM75/json-server.git

Navigate to the cloned directory:

cd json-server

Create api.json file with following structure:

{
  "port": 3000,
  "endpoints": [
    {
      "method": "GET",
      "status": 200,
      "path": "/users",
      "jsonPath": "./users.json"
    },
    {
      "method": "POST",
      "status": 201,
      "path": "/users/:userId/comments",
      "jsonPath": "./comment.json"
    }
  ]
}
  • port: port number that server will listen on.
  • method: specifies HTTP request method. Possible values are GET, POST, PUT, PATCH or DELETE.
  • jsonPath: path to .json file that represents contents of response.

Start JSON Server:

go run main.go