2024-03-25 15:15:48 -07:00

49 lines
2.5 KiB
Plaintext

Compile insert API_Setup
/***********************************************************************************************************************
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
permission from SRP Computer Solutions, Inc.
Name : API_Setup
Description : Sets up the current web API.
Notes : See the comments added below.
History : (Date, Initials, Notes)
11/17/18 dmb Original programmer. - [SRPFW-257]
02/03/19 dmb Update URLSegments logic to exclude the query params that are now returned by the
FullEndpointURL service. - [SRPFW-257]
02/11/19 dmb Add FullEndpointNoQuery variable. This is the same as the FullEndpointURL but strips off the
query params. This will be used by logic that needs the full endpoint and also needs to
append additional segments. - [SRPFW-257]
***********************************************************************************************************************/
Common /Debugging/ DebugFlag@
// Utility services.
Declare function Error_Services, HTTP_Services, HTTP_Resource_Services, RetStack
Declare subroutine Error_Services, HTTP_Services, HTTP_Resource_Services
// The API URL is fixed for any application but should be customized for the application itself. This is not always
// passed into the request correctly, especially if a proxy service or rewrite rules are being used.
APIURL = HTTP_Services('GetAPIRootURL', True$)
// The Full End Point URL indicates the URL submitted by the client.
FullEndpointURL = HTTP_Services('GetFullEndpointURL')
FullEndpointURLNoQuery = FullEndpointURL[1, 'F?']
URLSegments = FullEndpointURLNoQuery
If URLSegments[-1, 1] EQ '/' then URLSegments[-1, 1] = ''
Convert '/' to @FM in URLSegments
NumSegments = DCount(URLSegments, @FM)
ParentURL = Field(FullEndpointURL, '/', 1, NumSegments - 1)
EndpointSegment = URLSegments<NumSegments>
ParentSegment = URLSegments<NumSegments - 1>
// The HTTP method (or verb) submitted by the client.
HTTPMethod = HTTP_Services('GetHTTPRequestMethod')
// Get the name of the current service handler in case it needs to be used for error management.
CurrentAPI = RetStack()<1>