× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




The short(ish) answer is that it's built on Express, it basically just extracts the HTTP headers, along with host name, method, cookies and a bunch of other things and then passes them as a JSON object, together with the request body, to a despatcher stored procedure. The despatcher determines which application SP should process the request based on the route and method (although any other criteria available could be used, such as the "content-type" or "accepts" headers) and calls that.

The despatcher and the processing SPs have four parameters:
in REQUEST - a JSON object with the header data mentioned above
in REQUEST_BODY - a JSON object with the request body (mine are always JSON)
inout RESPONSE_DATA - a JSON object with the response data, similar to the header data mentioned above
out RESPONSE - a CLOB/BLOB/JSON/XML etc. with the response body

The SPs are able to inspect the REQUEST_DATA JSON parameter to find out the path or query parameters or any of the other information relevant to the call, populate the response body and fill in any relevant parts of the response header information, such as status code, or content-type.

Actually, while it's only about 80 lines of Typescript, there are another couple of hundred lines of SQL in the dispatching and route resolution SQL SPs, so a bit more than the few dozen lines I claimed! Also, the version I currently use against a MariaDB database (hence the slightly different SQL syntax above), I haven't ported it yet to the IBM i yet - but I don't see any issue doing that, there's nothing database specific in the code. In any case, I suspect that IWS might be able to do almost the same thing, so it might not even be necessary, but I haven't had time to look.

I'll stick the source on GitHub at some point, in case it's useful to someone.

Tim.



________________________________
From: WEB400 <web400-bounces@xxxxxxxxxxxxxxxxxx> on behalf of Steve Richter <stephenrichter@xxxxxxxxx>
Sent: 02 June 2021 17:12
To: Web Enabling the IBM i (AS/400 and iSeries) <web400@xxxxxxxxxxxxxxxxxx>
Subject: Re: [WEB400] IBM i as a webserver with low cost tools

if you're on 7.2 or later, you can even build the JSON responses right
in the SQL and then you only need a
very thin middleware layer (the one I currently use is just a few dozen
lines of Typescript).

how does this work?
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.