with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Exceptions;

with AWS.Server;
5with AWS.Config;
with AWS.Services.Dispatchers.URI;

with Bookstore_2.Requests_Processing;

10procedure Bookstore_2.Server is

   package TIO renames Ada.Text_IO;
   package IIO renames Ada.Integer_Text_IO;

15   Ws   : AWS.Server.Http;
   Conf : AWS.Config.Object := AWS.Config.Get_Current;
   H    : AWS.Services.Dispatchers.URI.Handler;


20begin
   TIO.New_Line;
   TIO.Put ("server starting, available at ");
   TIO.Put ("http://localhost:");
   IIO.Put (AWS.Config.Server_Port (Conf), 0);
25   TIO.New_Line;
   TIO.Put_Line ("Press <Enter> to quit");

   Requests_Processing.Process (H);

30   AWS.Server.Start
     (Web_Server => WS,
      Dispatcher => H,
      Config => Conf);

35   TIO.Skip_Line;

   AWS.Server.Shutdown (WS);

exception
40   when Error: others =>
      TIO.Put_Line ("bookstore_2-server.adb got an unexpected exception: ");
      TIO.Put_Line (Ada.Exceptions.Exception_Information(Error));
end Bookstore_2.Server;
top