1:- module(response,[
2 body/2,
3 content_type/2,
4 exists/1,
5 exists/2,
6 status_code/2,
7 well_formed/1
8]). 9
10
11:- use_module(library(error), []). 12:- use_module(library(record)). 13
14:- multifile error:has_type/2. 15error:has_type(response, Response) :-
16 response:well_formed(Response).
17
18:- record response( status_code:integer, content_type:atom, body:stream).
27exists(Response) :-
28 default_response(Response).
34exists(Response,Attributes) :-
35 maplist(term_pair,Terms,Attributes),
36 make_response(Terms,Response).
37
38term_pair(Term,Name-Value) :-
39 Term =.. [Name, Value].
45well_formed(Response) :-
46 is_response(Response).
53body(Response, Stream) :-
54 response_body(Response,Stream).
61content_type(Response, Type) :-
62 response_content_type(Response,Type).
69status_code(Response,Code) :-
70 response_status_code(Response,Code)