Support handling of multiple media types in Accept HTTP header
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.
Take a look at #155 and let me know what you think. I did not use dynamic lists as this would require users to clean up resources allocated by sList_new manually. I doubt there would ever be more values than maximum of 100 which is the current limit.
For future, we could think about introducing something like dispose methods for plugins that would be called after each request so the plugins could clean up resources they allocated.
Nice work. Good utility procedures. But we should move the code somewhere else as it is no plugin in the ILEastic sense of things.
Though we could turn this into a plugin but I don't think that this would make things better.
I would either make a new module mediatype.rpgmod or add it to the ileasticr.sqlrpgmod module. @NielsLiisberg What do you think?
At first I did everything in ileasticr.rpgmod but then I thought it would be better to make a plugin out of it. Looks like it was a wrong decision :) I can move it back to where it was at the beginning or to a separate module, just let me know.
@NielsLiisberg ping?!
I have been on a business trip, will look into it soon. stay tuned