synopse / mORMot2

OpenSource RESTful ORM/SOA/MVC Framework for Delphi and FreePascal
https://synopse.info
Other
485 stars 122 forks source link

Redirect Bug for TMvcRunOnRestServer.RunOnRestServerSub #209

Closed daselang closed 12 months ago

daselang commented 1 year ago

1. inherit TMVCApplication and implement Start with code:fMainRunner := TMvcRunOnRestServer.Create(Self, nil, 'bb', aViews); indexis the aRoot,bbis the value of param namedaSubURI, so it will go throughRunOnRestServerSub,so visiting /index/bb will trigger Ctxt.Redirect(Ctxt.UriWithoutSignature + '/default'), but the brower redirects to/index/index/bb/default,and caused 400 Bad Reqeuest I think it should be/index/bb/default as the right url.

2.if set /bbas the aSubURI,mORMot2 will not make it as a valid MethodName in ServiceMethodRegister,actually mapping bb to the same method name under TMVCApplication.

3.set bb/ as as the aSubURI.it works. but visiting /index/bb will not trigger any redirect in RunOnRestServerSub for it is mapped to method under TMVCApplication,only /index/bb/ works to trigger the redirection.

2 && 3, I think ,for normal user's perspective,both /index/bb and /index/bb/ without any more subUrls append,should be the same action.I think some optimizations should be updated to handle with the / in brower url and aSubURI,you can forbidden or delete the / in head and tail of the aSubURI when resgisting the service. and regard /index/bb/ as same as /index/bb,for users always copy the url and send to others but forget coppying the last /.

Maybe in mORMot1,it will be the same action,fix both if you think it is an issue.

synopse commented 1 year ago

Perhaps you could easily circumvent all this using the routing renaming at HTTP server level. https://blog.synopse.info/?post/2022/12/25/Efficient-Routing-for-Christmas

synopse commented 12 months ago

Please use HTTP routing for this.

Reopen if it is not enough.