- This topic has 1 reply, 2 voices, and was last updated 4 years, 8 months ago by
kimbomadsen.
-
AuthorPosts
-
-
May 12, 2021 at 09:10 #55746
VadimMest
ParticipantHello
How can I set “default” procedure for all GET requests for TkbmMWCustomSmartService for the purpose returning index.html ?
[kbmMW_Service(‘name:MOWAITER_RESTSERVICE, version:1.0, flags:[listed]’)]
[kbmMW_Rest(‘path:/’)]…….
[kbmMW_Rest(‘method:post, path:mobilewaiter/*’)]
[kbmMW_Method]
function PosFunction: String;[kbmMW_Rest(‘method:get, path:apk/mobilewaiter.apk’)]
[kbmMW_Method]
function GetApk: Variant;[kbmMW_Rest(‘method:get path:?????????????????’)]
[kbmMW_Method]
function GetIndexHTML: Variant;Thanks
-
May 12, 2021 at 18:21 #55747
kimbomadsen
KeymasterHi,
If you check the RESTFishFact demo, you can see demonstrated how one can provide both service local status handlers and webserver global status / default handlers.
A service local status handler is a handler (method) that triggers the moment a status code is about to be returned to the client, for example 404 which is the default HTTP status code when a client requests a page that is not found.
A web server global status / default handler, is a handler that kicks in when a request is resulting in a status code, for example because no service instances match the request.
Example of a service local status handler:
... [kbmMW_Rest('status:[302], mimeType:text/html')] function LocalStatus302Handler:string; [kbmMW_Rest('status:[303,304], mimeType:text/html')] function LocalStatus303_to_304Handler:string; ...And of a web server wide default handler:
[kbmMW_Service('name:DEFAULT_STATUS_HANDLER, flags:[STATUS,STRICT]')] TDefaultStatusHandler = class(TkbmMWCustomSmartService) private { Private declarations } protected { Protected declarations } public { Public declarations } // The anonymous (not named by the kbmMW_ErrorMethod attribute) DefaultErrorHandler function is // called when no other better matching error handlers are found. // Two optional arguments can be provided which includes the error code and message. [kbmMW_Rest('status:ANY, mimeType:text/html')] function DefaultStatusHandler([kbmMW_Arg(TkbmMWRTTIArgumentType.mwatHTTPStatusCode)] const AHTTPStatus:integer; [kbmMW_Arg(TkbmMWRTTIArgumentType.mwatStatusCode)] const AStatus:integer; [kbmMW_Arg(TkbmMWRTTIArgumentType.mwatStatusText)] const AStatusText:string; [kbmMW_Arg(TkbmMWRTTIArgumentType.mwatRemoteLocation)] const ACaller:string):string; end; ...As you can see the web server global handler needs to be registered with the service flag STATUS. Then it will be used if no other services match.
/Kim/C4D
-
-
AuthorPosts
- You must be logged in to reply to this topic.
