Static Handling

Setup static serving from static directory

*/

    7:- module(sw_static_handling,
    8    [ reply_file/2
    9    , reply_file/3
   10    ]
   11).   12
   13:- use_module(sw_config_handling).   14
   15:- use_module(library(http/thread_httpd)).   16:- use_module(library(http/http_dispatch)).   17:- use_module(library(http/http_files)).   18
   19http:location(static, "/static", []).
   20
   21:- get_config(static_dir, Dir),
   22   http_handler(static(.),
   23                http_reply_from_files(sw_app(Dir), []),
   24                [prefix]).
 reply_file(+File, +Request) is semidet
Respond with a file using default options
Arguments:
File- The path to the file to respond with, relative or absolute.
Request- The Request provided to the route
   33reply_file(File, Request) :-
   34    reply_file(File, [], Request).
 reply_file(+File, +Request) is semidet
Respond with a file with options as per [http_reply_file/3] from library(http/http_dispatch)
Arguments:
File- The path to the file to respond with, relative or absolute.
Options- As per http_reply_file/3
Request- The Request provided to the route
   46reply_file(File, Opts, Request) :-
   47    http_reply_file(sw_app(File), Opts, Request), !.
   48reply_file(File, Opts, Request) :-
   49    http_reply_file(File, Opts, Request)