totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 450 forks source link

Delete method return 404 #619

Closed oldCoder29 closed 6 years ago

oldCoder29 commented 6 years ago

I have a route which is: F.route('/1.1/charts/', handleCharts, ['delete','get','post','cors']); This route works fine with GET and POST but returns 404 response on delete.

what i did is:

F.route('/1.1/charts/', handleCharts, ['get','post','cors']);
F.route('/1.1/charts/', deleteChart, ['delete']);

Still the problem is same.

Now i did following and it worked:

F.route('/1.1/charts/', handleCharts, ['get','post','delete','cors']);
F.route('/1.1/charts/', deleteChart, ['delete']);

This is how my controller looks like:

exports.install = function () {

  // F.route('/1.1/charts/', saveChart, ['post']);
  F.route('/1.1/charts/', handleCharts, ['delete','get','post','cors']);
  F.route('/1.1/charts/', deleteChart, ['delete']);
};

async function handleCharts() {
  switch(this.req.method){
    case "GET":
    return listCharts(this);
    break;
    case "POST":
    return saveChart(this);
    break;
    case "DELETE":
    return deleteChart(this);
    break;
  }
}

async function listCharts(controllerThis){
  //do something
}

async function saveChart(controllerThis){
 //do something
}

async function deleteChart(controllerThis){
  //do something
}

All the requests are from browser.(CORS required)

petersirka commented 6 years ago

Hi, I'm solving it...

petersirka commented 6 years ago

Hi, I have fixed it, please try to install latest beta version: $ npm install total.js@beta and give me a feedback.

Thank you for the report!

oldCoder29 commented 6 years ago

Now it works!!..