sitemule / ILEastic

Embedded application server for ILE on IBM i
Apache License 2.0
58 stars 29 forks source link

Support handling of multiple media types in Accept HTTP header #84

Open m1h43l opened 4 years ago

m1h43l commented 4 years ago

Currently you can just retrieve the value of the Accept header. But the header can have multiple values like

application/json,application/xml,text/plain

or even with a priority

application/json,application/xml;q=0.6,text/plain;q=0.8

So some extra procedures for handling different media types would be great.

pointer il_getAcceptedMediaTypes(request); The returned pointer could be a simple list instance which is already in the project. We would just need to expose the list API by adding them to the binder source of the ILEastic service program.

varchar il_getPreferredAcceptedMediaType(request); This would return the accept http header with the highest priority. Could return / if none was provided.

varchar il_isMediaTypeAccepted(request : 'application/json' : ... : 'application/xml'); This would return the media type which ranks the highest in the list of accepted media types. As RPG cannot do variable number of parameter we would need to limit them to a fixed number and declare them as *nopass.