View source with raw comments or as raw
    1/*  Part of SWI-Prolog
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@vu.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (c)  2019, VU University Amsterdam
    7    All rights reserved.
    8
    9    Redistribution and use in source and binary forms, with or without
   10    modification, are permitted provided that the following conditions
   11    are met:
   12
   13    1. Redistributions of source code must retain the above copyright
   14       notice, this list of conditions and the following disclaimer.
   15
   16    2. Redistributions in binary form must reproduce the above copyright
   17       notice, this list of conditions and the following disclaimer in
   18       the documentation and/or other materials provided with the
   19       distribution.
   20
   21    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   22    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   23    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   24    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   25    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   26    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   27    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   28    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   29    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   31    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   32    POSSIBILITY OF SUCH DAMAGE.
   33*/
   34
   35:- module(http_server,
   36          [ http_server/1,		% +Options
   37            % from thread_httpd
   38            http_current_server/2,      % ?:Goal, ?Port
   39            http_server_property/2,     % ?Port, ?Property
   40            http_server/2,              % :Goal, +Options
   41            http_workers/2,             % +Port, ?WorkerCount
   42            http_add_worker/2,          % +Port, +Options
   43            http_current_worker/2,      % ?Port, ?ThreadID
   44            http_stop_server/2,         % +Port, +Options
   45            http_spawn/2,               % :Goal, +Options
   46            % from http_dispatch
   47            http_dispatch/1,            % +Request
   48            http_handler/3,             % +Path, +Predicate, +Options
   49            http_delete_handler/1,      % +Path
   50            http_request_expansion/2,   % :Goal, +Rank
   51            http_reply_file/3,          % +File, +Options, +Request
   52            http_redirect/3,            % +How, +Path, +Request
   53            http_404/2,                 % +Options, +Request
   54            http_switch_protocol/2,     % :Goal, +Options
   55            http_current_handler/2,     % ?Path, ?Pred
   56            http_current_handler/3,     % ?Path, ?Pred, -Options
   57            http_location_by_id/2,      % +ID, -Location
   58            http_link_to_id/3,          % +ID, +Parameters, -HREF
   59            http_reload_with_parameters/3, % +Request, +Parameters, -HREF
   60            % from http_wrapper
   61            http_current_request/1,     % -Request
   62            http_peer/2,
   63            % from http_parameters
   64            http_parameters/2,          % +Request, -Params
   65            http_parameters/3,
   66            % from html_write
   67            reply_html_page/2,          % :Head, :Body
   68            html//1,                    % :Content
   69                                        % Extension support
   70            (html_meta)/1,              % +Spec
   71            op(1150, fx, html_meta),
   72            % from http_json
   73            reply_json_dict/1,          % +JSON
   74            reply_json_dict/2,          % +JSON, Options
   75            http_read_json_dict/2,      % +Request, -Dict
   76            http_read_json_dict/3,      % +Request, -Dict, +Options
   77
   78            is_json_content_type/1
   79          ]).   80:- use_module(library(http/thread_httpd)).   81:- use_module(library(http/http_dispatch)).   82:- use_module(library(http/http_wrapper)).   83:- use_module(library(http/http_parameters)).   84:- use_module(library(http/html_write)).   85:- use_module(library(http/http_json)).   86:- use_module(library(http/http_dyn_workers)).

HTTP server library

This library combines the core server functionality provided by several libraries that are needed by almost any web server. It exports the commonly used predicates from library(http/thread_httpd), library(http/http_dispatch), library(http/http_wrapper), library(http/http_parameters), library(http/html_write), library(http/http_json), and library(http/http_dyn_workers).

*/

 http_server(+Options) is det
Create an HTTP server using http_dispatch/1 for handling requests. See http_server/2 and http_dispatch/1 for details.
  104http_server(Options) :-
  105    http_server(http_dispatch, Options)