Except for the :- initialization http_daemon., it works fine. This declaration leads to a double startup. The http_unix_daemon library uses initialization/2.
Test:
swipl s.pl --interactive --port=4001
% Started server at http://localhost:4001/
101 ?-
Following the build instructions worked flawlessly on my home PC, but was a bit more challenging on my web hosting company’s server where CentOS 7 had a too old version of cmake, so I had to install a newer version in my home directory, and then make failed because of tex, so I had to edit the CMake file to turn documentation off… but all good now.
The build doesn’t use LaTeX. It does various packages that are not so obvious such as archive. That should eventually be avoided by restructuring the modules that constitute PlDoc. It is wise to install all prerequisites to avoid these issues. You find the list for Redhat/Fedora/CentOS here
request reaches server but cant route it if the request has a parameter
embedded in the end point as “3fa85f64” in the above example. This value will be changed for every request. Its the request parameter.
Any concrete example for http handler in the server for the above kind of http request please ?
The above POST call should be routed to a method runHello in the server.pl and i tried
:- http_handler(root(hello/x/world), runHello, [X]).
If a segment is a variable it matches any segment and the binding may be passed to the closure. If the last segment is a variable it may match multiple segments. This allows registering REST paths, for example: …
(there could be a typo in the docs: methods([get,port,put]) should be methods([get,post,put]).)
So - I think - you should try to define your handler like
Thanks very much for the help. One more question though:
for my case, the ‘X’ in your example is a variable in every request and
Y is a string ‘projections’.
So as per your example, I should write like the below ? The server will substitute X for the new value every time ?
Again thanks so much in advance. Regards
Unfortunately it did not work. I never got the log message that proves whether the request was routed or not to the function. My request URL looks as : “http://localhost:1234/hello/3fa85f64/world”
when I call it from the browser with http://localhost:6789/api/v1/analytics/123123/analytics i get the html page with called runPrognosis(123123) . So, http_handler works as advised.
Maybe you should dive deeper in debugging the server, or double check the log…
Thanks again !!! Yes, it seems I tried POST and it failed. So
I tried like yours GET request through browser and using CURL and Postman and all worked… But the POST request still fails…anything I need to
add to this function or http_handler for handling Post request ?
Again thanks so much for your help…I really appreciate it
Regards