Methods

GET

Simple GET

$router->get("/",function(){
  // do something
})

Pass parameter through route

$router->get("/user/:id",function($id){
  echo $id;
})

POST

Post data must be JSON format

The below example is when user post to /api route, it will return posted data.

$router->post("/api",function($post_data){
   echo json_encode($post_data);
})

Note: Post doesn't accept route parameter like "/api/:id"

PUT

The post data send via PUT method must includes _id as object property & value

DELETE

The post data send via DELETE method must includes id as route parameter (e.g /posts/C3BF55677CA8225208BD9B6D77895126)

Last updated

Was this helpful?