Comments (6)
Hello!
I think you need something like this: https://gist.github.com/rla/b448a07d567bcc69650566a23b23c668.
See also docs for the http_server_hook
predicate.
from alternative-router.
I try this also
:- use_module(library(http/http_unix_daemon)).
:- use_module(library(arouter)).
http_unix_daemon:http_server_hook(Options) :-
http_server(handle_request, Options).
handle_request(Request) :-
( aroute(Request)
-> true
; http_dispatch(Request)).
:- route_get( hello/Name, handle_hello(Name) ).
handle_hello(Name):-
format('Content-Type: text/plain; charset=UTF-8~n~n'),
format('Hello ~w', [Name]).
:- initialization(http_daemon, main).
But the error is ERROR: service `true' does not exist
. IMHO the handle_request
is not bind correctly. With the example within the readme http_server
it works, but with http_daemon
it does not , but for a service I need the daemon call
Your given example breaks with the same service error
from alternative-router.
Tested this:
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_dispatch)).
:- use_module(library(http/http_unix_daemon)).
:- use_module(library(arouter)).
:- route_get(hello/Name, handle_hello(Name)).
handle_hello(Name):-
format('Content-Type: text/plain; charset=UTF-8~n~n'),
format('Hello ~w', [Name]).
http_unix_daemon:http_server_hook(Options):-
http_server(handle_request, Options).
handle_request(Request):-
( route(Request)
-> true
; http_dispatch(Request)).
:- initialization(http_daemon, main).
With command: swipl -s test.pl -- --port=8000 --interactive=true
.
from alternative-router.
Sorry, no it does not work, same error message, I run the script with swipl -O server.prolog --no-fork --port 8080
I need the --no-fork
option for the daemon, but I tested it with -s
and --interactive=true
. My SWI-Prolog version is 7.6.4
from alternative-router.
Make sure you got the right arouter package:
pack_install('http://packs.rlaanemets.com/alternative-router/arouter-1.1.1.tgz').
There is same pack with same name but from other author and a bit modified code.
And remove all other code, the example as-is must work. arouter
has no reference to any kind of services, it must be some other code.
from alternative-router.
I just reinstall the package with the URL, after that it works, thanks
from alternative-router.
Related Issues (8)
- Document root route and routes ending in slash HOT 1
- Provide list of currently registered routes HOT 1
- Validate route expressions. HOT 1
- Use asserta/1 in new_route/3 and new_route/4 to allow overriding. HOT 1
- Figure out what to do with catch-all route paths HOT 1
- Route not updated when before-goal is removed? HOT 1
- Warning: Predicate arouter:new_route/5 not defined HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alternative-router.