Handler id from another module does not work

I’m using: SWI-Prolog version 8.2.1

I want the code to:
do location_by_id(user_module:register_handler)
But what I’m getting is:
http_handler_id `user_module:register_handler’ does not exist
My code looks like this:

:- module(user_module,
          [ 
          ]).
:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_error)).
:- use_module(library(http/html_write)).

http:location(user, root(user), []).

:- http_handler(user(register), register, [id(register_handler)]).

register :-
	format('Content-type: text/html~n~n', []).

I am trying to call register_handler in the main module

        :- use_module(user_module).
        :- http_handler(root(.), index_controller, []).
        index_controller(_Request) :-
                reply_html_page(
        	   [
        	   	title('Howdy')
        	   ],
        	   [
        		div([class='register-form'], [
        			h1('Registration'),
        			form([method=post, action=location_by_id(user_module:register_handler)], [
        				input([type=text, name=text]),
        				input([type=text, name='name']),
        				input([type=submit, value='Send'])
        			])
        		])
        	   ]).

I believe the id for a handler is a global thing, so you shouldn’t need to add user_module: in the main module.

1 Like

Yes, it works. Hmm… I followed the official tutorial. Thank you

Which one?