Skip to content

Instantly share code, notes, and snippets.

@harryWonder
Created July 5, 2020 23:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harryWonder/faa0218e1dafcdad1d899ecdf476ca7e to your computer and use it in GitHub Desktop.
Save harryWonder/faa0218e1dafcdad1d899ecdf476ca7e to your computer and use it in GitHub Desktop.
The endpoints for the php-rest-api application
<?php
namespace App;
use App\UserController;
use App\CatalogController;
use App\ProductController;
$Klein = new \Klein\Klein();
/******************** User Routes || Authentication Routes **********************/
$Klein->respond('POST', '/api/v1/user', [ new UserController(), 'createNewUser' ]);
$Klein->respond('POST', '/api/v1/user-auth', [ new UserController(), 'login' ]);
/******************** Catalog Routes **********************/
$Klein->respond('POST', '/api/v1/catalog', [ new CatalogController(), 'createNewCatalog' ]);
$Klein->respond(['PATCH', 'PUT'], '/api/v1/catalog/[:id]', [ new CatalogController(), 'updateCatalog']);
$Klein->respond(['GET', 'HEAD'], '/api/v1/fetch-catalog-by-id/[:id]', [ new CatalogController(), 'fetchCatalogById' ]);
$Klein->respond(['GET', 'HEAD'], '/api/v1/fetch-catalog-by-name/[:name]', [ new CatalogController(), 'fetchCatalogByName' ]);
$Klein->respond(['GET', 'HEAD'], '/api/v1/catalogs', [ new CatalogController(), 'fetchCatalogs' ]);
$Klein->respond('DELETE', '/api/v1/del-catalog/[:id]', [ new CatalogController(), 'deleteCatalog' ]);
/******************** Product Routes **********************/
$Klein->respond('POST', '/api/v1/product', [ new ProductController(), 'createProduct' ]);
$Klein->respond('POST', '/api/v1/product/[:id]', [ new ProductController(), 'updateProduct' ]);
$Klein->respond('GET', '/api/v1/fetch/[:id]', [ new ProductController(), 'getProductById' ]);
$Klein->respond('GET', '/api/v1/products', [ new ProductController(), 'fetchProducts' ]);
$Klein->respond('DELETE', '/api/v1/delete-product/[:id]', [ new ProductController(), 'deleteProduct' ]);
// Dispatch all routes....
$Klein->dispatch();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment