× 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.



Looks great I will pretty much use most of it. But why so close to 100% using all free rpgle code did you stop ?


Thanks
John Slanina


On 12/7/18, 11:23 AM, "WEB400 on behalf of Kevin Bucknum" <web400-bounces@xxxxxxxxxxxx on behalf of Kevin@xxxxxxxxxxxxxxxxxxx> wrote:

Here is a quick example of the kinds of things I have done in the past. It is real ugly because I cobbled it together from several programs, but it shows the basics of my workflow.

https://code.midrange.com/bdb07ec0d1.html

Split the URI into the PATH and the QUERY_STRING.
Explode the PATH into an array that I can search or iterate through.
Explode the QUERY_STRING into an array.
Separate the QUERY_STRING array into two arrays. One with keys, and the other with associated values.

-----Original Message-----
From: WEB400 [mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Slanina, John
Sent: Friday, December 07, 2018 9:11 AM
To: Web Enabling the IBM i (AS/400 and iSeries)
Subject: Re: [WEB400] Uri Template

Looking at the JSON API Specification it have a couple of query strings. Sort , Filter and include, still not sure how I want to handle it.

I know I have to build a service program to handle it, just trying to think how and what to pass and in what format.


On 12/7/18, 9:55 AM, "WEB400 on behalf of Kevin Bucknum" <web400-bounces@xxxxxxxxxxxx on behalf of Kevin@xxxxxxxxxxxxxxxxxxx> wrote:

How are you getting the URI to parse? Which portions of it do you need? Query string and path?

-----Original Message-----
From: WEB400 [mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Slanina, John
Sent: Friday, December 07, 2018 8:40 AM
To: Web Enabling the IBM i (AS/400 and iSeries)
Subject: Re: [WEB400] Uri Template

I never mastered regular expressions, But I had to start using it now to validate all our Json api's. I partly understand what it is doing, But don’t want to hardcode the 20 URI formats in the sql select and still have to deal with parsing out the after the ? which has a lot of unknows. It's easy for the web programmer they have all the library that can parsing out everything for them.

I keep thinking if I am going down the right road write everything in RPGLE.

John Slanina



On 12/6/18, 1:03 PM, "WEB400 on behalf of Tim Fathers" <web400-bounces@xxxxxxxxxxxx on behalf of X700-IX2J@xxxxxxxxxxx> wrote:

Are you just wishing to parse the URI and pull out the parameters and query strings from it? If so regular expressions (regex) are probably the most popular way of doing that and perhaps the easiest way to use regex in RPG is using embedded SQL. There are some regex APIs too, they are more difficult to use, but obviously they're likely to be faster.

Here is a really basic SQL example you can run, bear in mind though that the patterns I have used here are just simple examples, in reality they'd need to be a *lot* smarter!!:

select regexp_substr(URI, PATTERN, 1, 1, '', 1) as CUSTOMER_NUMBER, -- Match group 1
regexp_substr(URI, PATTERN, 1, 1, '', 2) as ORDER_NUMBER, -- Match group 2
regexp_substr(URI, PATTERN, 1, 1, '', 3) as PAGE_NUMBER -- Match group 3

from(values(
'/customers/1/orders/42?page=7',
'\/customers\/([0-9]{1,9})\/orders\/([0-9]{1,9})?.*=([0-9]{1,9})'
)) x(
URI,
PATTERN
)

The "URI" field is an example URI and the "PATTERN" is the regular expression pattern it is looking for. Each parameter is defined as a "matching group" by surrounding it with round brackets. I've assumed here that all the parameters are numeric and can be between 1 and 9 digits long. Group 1 is the customer number, group 2 is the order number and group 3 is the page number. The backslashes before the forward slashes are needed to escape the latter as forward slashes have a special meaning in regex patterns.

In RPG you could implement this as a loop to extract the parameters to an array as in this (completely untested!) example:
: : : : : : : :
dcl-s uriParm varchar(256);
dcl-s uriParms like(uriParm) dim(MAX_PARMS);
dcl-s group int(5);
dcl-s nullInd int(5);

for group = 1 to %elem(uriParms);
exec sql set :uriParm :nullInd = regexp_substr(URI, PATTERN, 1, 1, '', :group);
if nullInd < 0;
leave;
endif;

uriParms(group) = uriParm;

endfor;
: : : : : : : :

Tim.






________________________________
From: WEB400 <web400-bounces@xxxxxxxxxxxx> on behalf of Slanina, John <jslanina@xxxxxxxxxx>
Sent: 06 December 2018 17:59
To: web400@xxxxxxxxxxxx
Subject: [WEB400] Uri Template

We are try to switch for a free form json specification to Json api specification https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fjsonapi.org&amp;data=02%7C01%7C%7Cf4d9595e3cae47d7332508d65b9c4758%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636797124096034252&amp;sdata=q1fVA%2BeP1cQGK6RWZa9y2eMu7MGOVjlXU3SI2yCB8gU%3D&amp;reserved=0 for all are API’s

The one project I am working now is to create a URI Template System , kinda like org.springframework.web.util.UriTemplate but for the iseries.


Before all the variables where in the Json doc that was sent via the POST method and then we just used Scott’s YAJL to get the values.



Now we need to parse out the URI and look for information.



I am looking for any input on the best direction to go. We have well over a 100 Api’s we would like to change and we create more each day.




Thanks

John Slanina



--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fweb400&amp;data=02%7C01%7C%7Cf4d9595e3cae47d7332508d65b9c4758%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636797124096034252&amp;sdata=GoBinHvilQ5epVlh06Sm82bsr01AS%2FEoyhtImYw27Zs%3D&amp;reserved=0
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fweb400&amp;data=02%7C01%7C%7Cf4d9595e3cae47d7332508d65b9c4758%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636797124096034252&amp;sdata=Bf9GWYRgqnJQO0W2POtep%2F1tiS%2BA4f2jvsFtx4uTzRc%3D&amp;reserved=0.

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



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



[https://www.medtronsoftware.com/img/MedtronMinilogo.bmp] Kevin Bucknum
Senior Programmer Analyst
MEDDATA / MEDTRON
120 Innwood Drive
Covington LA 70433
Local: 985-893-2550
Toll Free: 877-893-2550
https://www.medtronsoftware.com



CONFIDENTIALITY NOTICE

This document and any accompanying this email transmission contain confidential information, belonging to the sender that is legally privileged. This information is intended only for the use of the individual or entity named above. The authorized recipient of this information is prohibited from disclosing this information to any other party and is required to destroy the information after its stated need has been fulfilled. If you are not the intended recipient, or the employee of agent responsible to deliver it to the intended recipient, you are hereby notified that any disclosure, copying, distribution or action taken in reliance on the contents of these documents is STRICTLY PROHIBITED. If you have received this email in error, please notify the sender immediately to arrange for return or destruction of these documents.
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.



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



[https://www.medtronsoftware.com/img/MedtronMinilogo.bmp] Kevin Bucknum
Senior Programmer Analyst
MEDDATA / MEDTRON
120 Innwood Drive
Covington LA 70433
Local: 985-893-2550
Toll Free: 877-893-2550
https://www.medtronsoftware.com



CONFIDENTIALITY NOTICE

This document and any accompanying this email transmission contain confidential information, belonging to the sender that is legally privileged. This information is intended only for the use of the individual or entity named above. The authorized recipient of this information is prohibited from disclosing this information to any other party and is required to destroy the information after its stated need has been fulfilled. If you are not the intended recipient, or the employee of agent responsible to deliver it to the intended recipient, you are hereby notified that any disclosure, copying, distribution or action taken in reliance on the contents of these documents is STRICTLY PROHIBITED. If you have received this email in error, please notify the sender immediately to arrange for return or destruction of these documents.
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
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.