text stringlengths 0 234 |
|---|
-- ------------------------------ |
procedure Start (Server : in out Container) is |
begin |
if Server.Applications /= null then |
for Application of Server.Applications.all loop |
if Application.Context.Get_Status = Core.Ready then |
Log.Info ("Starting application {0}", Application.Base_URI); |
Application.Context.Start; |
end if; |
end loop; |
end if; |
Server.Is_Started := True; |
end Start; |
-- ------------------------------ |
-- Receives standard HTTP requests from the public service method and |
-- dispatches them to the Do_XXX methods defined in this class. This method |
-- is an HTTP-specific version of the Servlet.service(Request, Response) |
-- method. There's no need to override this method. |
-- ------------------------------ |
procedure Service (Server : in Container; |
Request : in out Requests.Request'Class; |
Response : in out Responses.Response'Class) is |
use Util.Strings; |
URI : constant String := Request.Get_Request_URI; |
Slash_Pos : constant Natural := Index (URI, '/', URI'First + 1); |
Apps : constant Binding_Array_Access := Server.Applications; |
Prefix_End : Natural; |
begin |
if Apps = null then |
Response.Set_Status (Responses.SC_NOT_FOUND); |
Server.Default.Send_Error_Page (Request, Response); |
return; |
end if; |
-- Find the module and action to invoke |
if Slash_Pos > 1 then |
Prefix_End := Slash_Pos - 1; |
else |
Prefix_End := URI'Last; |
end if; |
for Application of Apps.all loop |
if Application.Base_URI = URI (URI'First .. Prefix_End) |
and then Application.Context.Get_Status = Core.Started |
then |
declare |
Req : Request_Context; |
Context : constant Core.Servlet_Registry_Access := Application.Context; |
Page : constant String := URI (Prefix_End + 1 .. URI'Last); |
Dispatcher : constant Core.Request_Dispatcher |
:= Context.Get_Request_Dispatcher (Page); |
begin |
Log.Info ("{0} {1}", Request.Get_Method, Page); |
Req.Request := Request'Unchecked_Access; |
Req.Response := Response'Unchecked_Access; |
Req.Application := Context; |
Set_Context (Req); |
Core.Forward (Dispatcher, Request, Response); |
case Response.Get_Status / 100 is |
when 2 | 3 => |
null; |
when others => |
if not Response.Is_Committed then |
Context.Send_Error_Page (Request, Response); |
end if; |
end case; |
Set_Context (Null_Context); |
return; |
exception |
when E : others => |
Context.Error (Request, Response, E); |
Set_Context (Null_Context); |
return; |
Function Definition: function Get_Request_Dispatcher (Context : in Servlet_Registry; |
Function Body: Path : in String) |
return Request_Dispatcher is |
use type Filters.Filter_List_Access; |
begin |
return R : Request_Dispatcher do |
Context.Routes.Find_Route (Path, R.Context); |
if not Routes.Is_Null (R.Context) then |
declare |
use Routes.Servlets; |
Route : constant Routes.Route_Type_Accessor := Routes.Get_Route (R.Context); |
begin |
if Route in Routes.Servlets.Servlet_Route_Type'Class then |
declare |
Servlet_Route : constant access Routes.Servlets.Servlet_Route_Type'Class |
:= Routes.Servlets.Servlet_Route_Type'Class (Route.Element.all)'Access; |
Proxy : Routes.Servlets.Proxy_Route_Type_Access; |
begin |
if Servlet_Route.Filters /= null then |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.