1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 18:37:05 +00:00

reorganization of _examples and add some new examples such as iris+groupcache+mysql+docker

Former-commit-id: ed635ee95de7160cde11eaabc0c1dcb0e460a620
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-06-07 15:26:06 +03:00
parent 9fdcb4c7fb
commit ed45c77be5
328 changed files with 4262 additions and 41621 deletions

View File

@@ -0,0 +1,5 @@
{
"title": "computer-internet",
"position": 2,
"image_url": "https://bp.pstatic.gr/public/dist/images/1mOPxYtw1k.webp"
}

View File

@@ -0,0 +1,31 @@
[{
"title": "product-1",
"image_url": "https://images.product1.png",
"price": 42.42,
"description": "a description for product-1"
}, {
"title": "product-2",
"image_url": "https://images.product2.png",
"price": 32.1,
"description": "a description for product-2"
}, {
"title": "product-3",
"image_url": "https://images.product3.png",
"price": 52321321.32,
"description": "a description for product-3"
}, {
"title": "product-4",
"image_url": "https://images.product4.png",
"price": 77.4221,
"description": "a description for product-4"
}, {
"title": "product-5",
"image_url": "https://images.product5.png",
"price": 55.1,
"description": "a description for product-5"
}, {
"title": "product-6",
"image_url": "https://images.product6.png",
"price": 53.32,
"description": "a description for product-6"
}]

View File

@@ -0,0 +1,6 @@
{
"id": 2,
"position": 1,
"title": "computers",
"image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Desktop_computer_clipart_-_Yellow_theme.svg/1200px-Desktop_computer_clipart_-_Yellow_theme.svg.png"
}

View File

@@ -0,0 +1,3 @@
{
"title": "computers-technology"
}

View File

@@ -0,0 +1,484 @@
{
"info": {
"_postman_id": "d3a2fdf6-9ebd-4e85-827d-385592a71fd6",
"name": "myapp (api-test)",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Category",
"item": [
{
"name": "Create",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODk2MzkzNjd9.cYohwgUpe-Z7ac0LPpz4Adi5QXJmtwD1ZRpXrMUMPN0",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"title\": \"computer-internet\",\r\n \"position\": 1,\r\n \"image_url\": \"https://bp.pstatic.gr/public/dist/images/1mOPxYtw1k.webp\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://localhost:8080/category",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"category"
]
},
"description": "Create a Category"
},
"response": []
},
{
"name": "Get By ID",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/category/1",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"category",
"1"
]
},
"description": "Get By ID"
},
"response": []
},
{
"name": "List",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://localhost:8080/category?offset=0&limit=30&order=asc",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"category"
],
"query": [
{
"key": "offset",
"value": "0"
},
{
"key": "limit",
"value": "30"
},
{
"key": "order",
"value": "asc"
}
]
},
"description": "Get many with limit offset"
},
"response": []
},
{
"name": "Update (Full)",
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODk1ODU1NjN9.PtfDS1niGoZ7pV6kplI-_q1fVKLnknQ3IwcrLZhoVCU",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n\t\"id\": 1,\r\n\t\"position\": 3,\r\n \"title\": \"computers\",\r\n \"image_url\":\"https://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Desktop_computer_clipart_-_Yellow_theme.svg/1200px-Desktop_computer_clipart_-_Yellow_theme.svg.png\"\r\n}"
},
"url": {
"raw": "http://localhost:8080/category",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"category"
],
"query": [
{
"key": "",
"value": null,
"disabled": true
}
]
},
"description": "Update a Category (full update)"
},
"response": []
},
{
"name": "Delete By ID",
"request": {
"method": "DELETE",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODk1ODU1NjN9.PtfDS1niGoZ7pV6kplI-_q1fVKLnknQ3IwcrLZhoVCU",
"type": "text"
}
],
"url": {
"raw": "http://localhost:8080/category/1",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"category",
"1"
]
},
"description": "Delete a Category"
},
"response": []
},
{
"name": "Update (Partial)",
"request": {
"method": "PATCH",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODk1ODU1NjN9.PtfDS1niGoZ7pV6kplI-_q1fVKLnknQ3IwcrLZhoVCU",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"title\": \"computers-technology\"\r\n}"
},
"url": {
"raw": "http://localhost:8080/category/1",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"category",
"3"
]
},
"description": "Update a Category partially, e.g. title only"
},
"response": []
},
{
"name": "List Products",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/category/1/products?offset=0&limit=30&by=price&order=asc",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"category",
"3",
"products"
],
"query": [
{
"key": "offset",
"value": "0"
},
{
"key": "limit",
"value": "30"
},
{
"key": "by",
"value": "price"
},
{
"key": "order",
"value": "asc"
}
]
},
"description": "Get products from cheap to expensive"
},
"response": []
},
{
"name": "Insert Products",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODk1ODU1NjN9.PtfDS1niGoZ7pV6kplI-_q1fVKLnknQ3IwcrLZhoVCU",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "[{\r\n \"title\": \"product-1\",\r\n \"image_url\": \"https://images.product1.png\",\r\n \"price\": 42.42,\r\n \"description\": \"a description for product-1\"\r\n}, {\r\n \"title\": \"product-2\",\r\n \"image_url\": \"https://images.product2.png\",\r\n \"price\": 32.1,\r\n \"description\": \"a description for product-2\"\r\n}, {\r\n \"title\": \"product-3\",\r\n \"image_url\": \"https://images.product3.png\",\r\n \"price\": 52321321.32,\r\n \"description\": \"a description for product-3\"\r\n}, {\r\n \"title\": \"product-4\",\r\n \"image_url\": \"https://images.product4.png\",\r\n \"price\": 77.4221,\r\n \"description\": \"a description for product-4\"\r\n}, {\r\n \"title\": \"product-5\",\r\n \"image_url\": \"https://images.product5.png\",\r\n \"price\": 55.1,\r\n \"description\": \"a description for product-5\"\r\n}, {\r\n \"title\": \"product-6\",\r\n \"image_url\": \"https://images.product6.png\",\r\n \"price\": 53.32,\r\n \"description\": \"a description for product-6\"\r\n}]"
},
"url": {
"raw": "http://localhost:8080/category/1/products",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"category",
"3",
"products"
]
},
"description": "Batch Insert Products to a Category"
},
"response": []
}
],
"protocolProfileBehavior": {}
},
{
"name": "Product",
"item": [
{
"name": "List",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/product?offset=0&limit=30&by=price&order=asc",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"product"
],
"query": [
{
"key": "offset",
"value": "0"
},
{
"key": "limit",
"value": "30"
},
{
"key": "by",
"value": "price"
},
{
"key": "order",
"value": "asc"
}
]
},
"description": "List products"
},
"response": []
},
{
"name": "Get By ID",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/product/1",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"product",
"1"
]
},
"description": "Get a Product"
},
"response": []
},
{
"name": "Delete By ID",
"request": {
"method": "DELETE",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODk1ODU1NjN9.PtfDS1niGoZ7pV6kplI-_q1fVKLnknQ3IwcrLZhoVCU",
"type": "text"
}
],
"url": {
"raw": "http://localhost:8080/product/3",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"product",
"3"
]
},
"description": "Delete a Product"
},
"response": []
},
{
"name": "Create",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODk1ODU1NjN9.PtfDS1niGoZ7pV6kplI-_q1fVKLnknQ3IwcrLZhoVCU",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"title\": \"product-1\",\r\n \"category_id\": 1,\r\n \"image_url\": \"https://images.product1.png\",\r\n \"price\": 42.42,\r\n \"description\": \"a description for product-1\"\r\n}"
},
"url": {
"raw": "http://localhost:8080/product",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"product"
]
},
"description": "Create a Product (and assign a category)"
},
"response": []
},
{
"name": "Update (Full)",
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODk1ODU1NjN9.PtfDS1niGoZ7pV6kplI-_q1fVKLnknQ3IwcrLZhoVCU",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n\t\"id\":19,\r\n \"title\": \"product-9-new\",\r\n \"category_id\": 1,\r\n \"image_url\": \"https://images.product19.png\",\r\n \"price\": 20,\r\n \"description\": \"a description for product-9-new\"\r\n}"
},
"url": {
"raw": "http://localhost:8080/product",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"product"
]
},
"description": "Update a Product (full-update)"
},
"response": []
},
{
"name": "Update (Partial)",
"request": {
"method": "PATCH",
"header": [
{
"key": "Authorization",
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODk1ODU1NjN9.PtfDS1niGoZ7pV6kplI-_q1fVKLnknQ3IwcrLZhoVCU",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"title\": \"product-9-new-title\"\r\n}"
},
"url": {
"raw": "http://localhost:8080/product/9",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"product",
"9"
]
},
"description": "Update a Product (partially)"
},
"response": []
}
],
"description": "Product Client API",
"protocolProfileBehavior": {}
},
{
"name": "Get Token",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/token",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"token"
]
},
"description": "Get Token to access \"write\" (create, update and delete) endpoints"
},
"response": []
}
],
"protocolProfileBehavior": {}
}

View File

@@ -0,0 +1,7 @@
{
"title": "product-1",
"category_id": 3,
"image_url": "https://images.product1.png",
"price": 42.42,
"description": "a description for product-1"
}

View File

@@ -0,0 +1,3 @@
{
"title": "product-19-new-title"
}

View File

@@ -0,0 +1,8 @@
{
"id":19,
"title": "product-19",
"category_id": 3,
"image_url": "https://images.product19.png",
"price": 20,
"description": "a description for product-19"
}

View File

@@ -0,0 +1,33 @@
CREATE DATABASE IF NOT EXISTS myapp DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE myapp;
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS categories;
CREATE TABLE categories (
id int(11) NOT NULL AUTO_INCREMENT,
title varchar(255) NOT NULL,
position int(11) NOT NULL,
image_url varchar(255) NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
DROP TABLE IF EXISTS products;
CREATE TABLE products (
id int(11) NOT NULL AUTO_INCREMENT,
category_id int,
title varchar(255) NOT NULL,
image_url varchar(255) NOT NULL,
price decimal(10,2) NOT NULL,
description text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
FOREIGN KEY (category_id) REFERENCES categories(id)
);
SET FOREIGN_KEY_CHECKS = 1;