You are not logged in.
Pages: 1
MVC right now is able to handle get and post (add/update) but it cannot handle delete request so I would like to propose to change TMvcRunOnRestServer.InternalRunOnRestServer
if Ctxt.Method in [mGET, mPOST] then
to
if Ctxt.Method in [mGET, mPOST, mDELETE] then
Or better yet allow for each of MVC methods to specify list of supported http methods
Offline
Note that the MVC requests are expected to be regular HTTP/Web request from HTML, so are usually GET and sometimes POST (from a form).
Other methods are not supported: https://stackoverflow.com/a/73880506/458259
So my guess is that you use mDELETE because you use the MVC as a single input for both HTML/web and JSON/RPC requests.
If we add mDELETE the we should add also mPUT I guess, for consistency.
And nothing prevent you to handle any other kind of method...
I also suspect it is not enough to add mDELETE here to see it available.
Because the methods are part of the URI registration in Create.
Please try https://github.com/synopse/mORMot2/commit/82ecb05f
Offline
Thanks, this will be perfect.
I'm actully not serving any json to client, it's just standard get to display object record (user for example), post to add/update it and for delete I had to add a custom DeleteUser method. Now with this change it's possible to handle all general actions (get, add, update, delete) in one method which is quite neat.
I'm using htmx library with mORMot MVC and with it client application is not bound to html FORM restrictions (GET/POST only).
Html form is not even needed (it can collect input values from a standard div) and it can issue delete request as well.
It offers some really nice features so it's possible to create complex applications without much javascript on client side.
For example when new user is added/deleted by client it can automatically append/delete it to the list, so it's not necessary to refresh whole page.
Offline
Note that the MVC requests are expected to be regular HTTP/Web request from HTML, so are usually GET and sometimes POST (from a form).
....
Please try https://github.com/synopse/mORMot2/commit/82ecb05f
Arnold I see your commit and I think that u put erro on your code no?
fAllowedMethods by default is [mGET, mPOST] but in some parts of code was [mGET, mHEAD]
sample
if publishMvcInfo in fPublishOptions then
fRestServer.ServiceMethodRegister(
before:
MVCINFO_URI, RunOnRestServerRoot, bypass, [mGET, mHEAD]);
now:
MVCINFO_URI, RunOnRestServerRoot, bypass, fAllowedMethods);
Offline
Pages: 1