Project

General

Profile

Is static resource URL parameter optional?

Added by Plug Gulp about 3 years ago

I have a static resource, EResource, deployed at the following endpoint:

/endpoint/${p1}/${p2} i.e. server.addResource(&res, "/endpoint/${p1}/${p2}");

From the documentation of Http::Request::urlParam the parameters can be empty i.e. optional in the URL. So the static resource EResource can be accessed using either /endpoint/${p1}/${p2} or /endpoint/${p1} or just /endpoint

Is my understanding correct? Because I am not seeing this behaviour. If I access /endpoint or /endpoint/pv1 then I get 404 error, but if I access /endpoint/pv1/pv2 then it works i.e. ${p1} == pv1 and ${p2} == pv2


Replies (2)

RE: Is static resource URL parameter optional? - Added by Korneel Dumon about 3 years ago

Hi,

do you mean the line that says "If the given parameter is not available, an empty string is returned."?

I think it means if you request a parameter that's not specified, eg. if the URL is /endpoint/${p1}/${p2} and you are asking for urlParam("p3")

RE: Is static resource URL parameter optional? - Added by Plug Gulp about 3 years ago

do you mean the line that says "If the given parameter is not available, an empty string is returned."?

Yes.

I think it means if you request a parameter that's not specified, eg. if the URL is /endpoint/${p1}/${p2} and you are asking for urlParam("p3")

Ah, okay. And I thought the parameter p1 and or p2!

Thank you for the clarification.

    (1-2/2)