text stringlengths 0 234 |
|---|
procedure Add_Route (Registry : in out Servlet_Registry; |
Pattern : in String; |
ELContext : in EL.Contexts.ELContext'Class; |
Process : not null access |
procedure (Route : in out Routes.Route_Type_Ref)) is |
begin |
Registry.Routes.Add_Route (Pattern, ELContext, Process); |
end Add_Route; |
-- ------------------------------ |
-- Set the error page that will be used if a servlet returns an error. |
-- ------------------------------ |
procedure Set_Error_Page (Server : in out Servlet_Registry; |
Error : in Integer; |
Page : in String) is |
begin |
Log.Info ("Using page {0} for http error {1}", Page, Integer'Image (Error)); |
Server.Error_Pages.Include (Error, Page); |
end Set_Error_Page; |
function Hash (N : Integer) return Ada.Containers.Hash_Type is |
begin |
return Ada.Containers.Hash_Type (N); |
end Hash; |
-- ------------------------------ |
-- Send the error page content defined by the response status. |
-- ------------------------------ |
procedure Send_Error_Page (Server : in Servlet_Registry; |
Request : in out Requests.Request'Class; |
Response : in out Responses.Response'Class) is |
URI : constant String := Request.Get_Request_URI; |
Status : constant Natural := Response.Get_Status; |
Pos : constant Error_Maps.Cursor := Server.Error_Pages.Find (Status); |
begin |
Request.Set_Attribute ("servlet.error.status_code", EL.Objects.To_Object (Integer (Status))); |
Request.Set_Attribute ("servlet.error.request_uri", EL.Objects.To_Object (URI)); |
if Error_Maps.Has_Element (Pos) then |
declare |
Page : constant String := Error_Maps.Element (Pos); |
Dispatcher : constant Request_Dispatcher |
:= Server.Get_Request_Dispatcher (Page); |
begin |
Forward (Dispatcher, Request, Response); |
return; |
exception |
when others => |
null; |
Function Definition: procedure Register_Application (Registry : in out Servlet_Registry; |
Function Body: URI : in String) is |
begin |
Registry.Context_Path := To_Unbounded_String (URI); |
end Register_Application; |
-- ------------------------------ |
-- Finalize the servlet registry releasing the internal mappings. |
-- ------------------------------ |
overriding |
procedure Finalize (Registry : in out Servlet_Registry) is |
begin |
-- Release the filter mapping lists that have been allocated. |
while not Registry.Filter_Rules.Is_Empty loop |
declare |
Pos : Filter_List_Maps.Cursor := Registry.Filter_Rules.First; |
Filter : Filter_List_Access := Filter_List_Maps.Element (Pos).all'Access; |
begin |
Free (Filter); |
Registry.Filter_Rules.Delete (Pos); |
Function Definition: procedure Free is |
Function Body: new Ada.Unchecked_Deallocation (Object => String, Name => String_Access); |
begin |
Free (Context.Path); |
end Finalize; |
-- ------------------------------ |
-- Insert the route node at the correct place in the children list |
-- according to the rule kind. |
-- ------------------------------ |
procedure Insert (Parent : in Route_Node_Access; |
Node : in Route_Node_Access; |
Kind : in Route_Match_Type) is |
Previous, Current : Route_Node_Access; |
begin |
Current := Parent.Children; |
case Kind is |
-- Add at head of the list. |
when YES_MATCH => |
null; |
when MAYBE_MATCH => |
while Current /= null loop |
if not (Current.all in Path_Node_Type'Class) then |
exit; |
end if; |
Previous := Current; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.