Giter VIP home page Giter VIP logo

product's Introduction

Overview

This is a dead simple server implementing RESTful API. Please find below all methods description and examples. All dependencies are stored in Godep vendor folders. By default it's running at 3000 port, but you can change it using -port parameter.

Create Product

curl -X POST -H "Content-Type: application/json; charset=utf-8" -d '{"Name":"New Product", "Description": "Should be cool", "Price": 5.0, "Tags":["new", "cool"]}' "http://localhost:3000/products"

REQUEST HEADERS

Content-Type: application/json; charset=utf-8

REQUEST BODY

{
	"Name": "New Product", 

	"Description": "Should be cool", 

	"Price": 5.0, 

	"Tags": ["new", "cool"]
}

RESPONSE HEADERS

content-type: application/json; charset=utf-8

status: 200 OK

RESPONSE BODY

{
	"ID": 1
}

Update Product

curl -X PUT -H "Content-Type: application/json; charset=utf-8" -d '{"Name":"New Product Updated", "Description": "Should be cool", "Price": 15.0, "Tags":["new", "cool", "updated"]}' "http://localhost:3000/products/1"

REQUEST HEADERS

Content-Type: application/json; charset=utf-8

REQUEST BODY

{
	"Name": "New Product Updated", 

	"Description": "Should be cool", 

	"Price": 15.0, 

	"Tags": ["new", "cool", "updated"]
}

RESPONSE HEADERS

content-type: application/json; charset=utf-8

status: 200 OK

RESPONSE BODY

List Products

curl -X GET -H "Content-Type: application/json; charset=utf-8" "http://localhost:3000/products"

REQUEST HEADERS

Content-Type: application/json; charset=utf-8

REQUEST BODY

RESPONSE HEADERS

content-type: application/json; charset=utf-8

status: 200 OK

RESPONSE BODY

{
	[
		{
			"ID": 1,

			"Name": "New Product Updated",

			"Description": "Should be cool",

			"Price": 15, 

			"Tags": ["new", "cool", "updated"]
		}
	]
}

Set Prices

curl -X PUT -H "Content-Type: application/json; charset=utf-8" -d '{"EUR": 20.15, "RUR":100.75}' "http://localhost:3000/products/1/prices"

REQUEST HEADERS

Content-Type: application/json; charset=utf-8

REQUEST BODY

{
	"EUR": 20.15, 

	"RUR": 1000.75, 
}

RESPONSE HEADERS

content-type: application/json; charset=utf-8

status: 200 OK

RESPONSE BODY

Get Product

curl -X GET -H "Content-Type: application/json; charset=utf-8" "http://localhost:3000/products/1"

REQUEST HEADERS

Content-Type: application/json; charset=utf-8

REQUEST BODY

RESPONSE HEADERS

content-type: application/json; charset=utf-8

status: 200 OK

RESPONSE BODY

{
	"ID": 1,

	"Name": "New Product Updated",

	"Description": "Should be cool",

	"Price": 15, 

	"Tags": ["new", "cool", "updated"],

	"Prices":{"EUR": 20.15, "RUR": 100.75}
}

Delete Product

curl -X DELETE -H "Content-Type: application/json; charset=utf-8" "http://localhost:3000/products/1"

REQUEST HEADERS

Content-Type: application/json; charset=utf-8

REQUEST BODY

RESPONSE HEADERS

content-type: application/json; charset=utf-8

status: 200 OK

RESPONSE BODY

Status codes

  • 200 - OK, success
  • 400 - Bad request with wrong product data
  • 404 - Product is not found
  • 500 - Internal server error

product's People

Contributors

vsukhin avatar

Watchers

James Cloos 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.