text
stringlengths 0
234
|
|---|
-- ------------------------------
|
-- Append the filter in the filter list.
|
-- ------------------------------
|
procedure Append (Key : in String;
|
List : in out Filter_List_Access) is
|
pragma Unreferenced (Key);
|
use Filters;
|
Filter : constant Filters.Filter_Access := Filter_Maps.Element (Pos).all'Access;
|
New_List : Filter_List_Access;
|
begin
|
-- Check that the filter is not already executed.
|
for I in List'Range loop
|
if List (I) = Filter then
|
return;
|
end if;
|
end loop;
|
New_List := new Filters.Filter_List (1 .. List'Last + 1);
|
New_List.all (2 .. New_List'Last) := List.all;
|
New_List (New_List'First) := Filter;
|
Free (List);
|
List := New_List;
|
end Append;
|
List : Filter_List_Access;
|
begin
|
Log.Info ("Add filter mapping {0} -> {1}", Pattern, Name);
|
if not Filter_Maps.Has_Element (Pos) then
|
Log.Error ("No servlet filter {0}", Name);
|
raise Servlet_Error with "No servlet filter " & Name;
|
end if;
|
if not Filter_List_Maps.Has_Element (Rule) then
|
Registry.Filter_Patterns.Append (Pattern);
|
List := new Filters.Filter_List (1 .. 1);
|
List (List'First) := Filter_Maps.Element (Pos).all'Access;
|
Registry.Filter_Rules.Insert (Pattern, List);
|
else
|
Registry.Filter_Rules.Update_Element (Rule, Append'Access);
|
end if;
|
end Add_Filter_Mapping;
|
-- ------------------------------
|
-- Add a servlet mapping with the given pattern
|
-- If the URL pattern is already mapped to a different servlet,
|
-- no updates will be performed.
|
-- ------------------------------
|
procedure Add_Mapping (Registry : in out Servlet_Registry;
|
Pattern : in String;
|
Name : in String) is
|
Pos : constant Servlet_Maps.Cursor := Registry.Servlets.Find (Name);
|
begin
|
if not Servlet_Maps.Has_Element (Pos) then
|
Log.Error ("No servlet {0}", Name);
|
raise Servlet_Error with "No servlet " & Name;
|
end if;
|
Log.Info ("Add servlet mapping {0} -> {1}", Pattern, Name);
|
Registry.Add_Mapping (Pattern, Servlet_Maps.Element (Pos));
|
end Add_Mapping;
|
-- ------------------------------
|
-- Add a servlet mapping with the given pattern
|
-- If the URL pattern is already mapped to a different servlet,
|
-- no updates will be performed.
|
-- ------------------------------
|
procedure Add_Mapping (Registry : in out Servlet_Registry;
|
Pattern : in String;
|
Server : in Servlet_Access) is
|
procedure Insert (Route : in out Routes.Route_Type_Ref);
|
procedure Insert (Route : in out Routes.Route_Type_Ref) is
|
To : Routes.Servlets.Servlet_Route_Type_Access;
|
begin
|
if Route.Is_Null then
|
To := new Routes.Servlets.Servlet_Route_Type;
|
To.Servlet := Server;
|
Route := Routes.Route_Type_Refs.Create (To.all'Access);
|
else
|
Log.Warn ("Mapping {0} already defined", Pattern);
|
end if;
|
end Insert;
|
Context : aliased EL.Contexts.Default.Default_Context;
|
begin
|
if Pattern'Length = 0 or else Server = null then
|
return;
|
end if;
|
Registry.Routes.Add_Route (Pattern, Context, Insert'Access);
|
end Add_Mapping;
|
-- ------------------------------
|
-- Add a route associated with the given path pattern. The pattern is split into components.
|
-- Some path components can be a fixed string (/home) and others can be variable.
|
-- When a path component is variable, the value can be retrieved from the route context.
|
-- Once the route path is created, the <tt>Process</tt> procedure is called with the route
|
-- reference.
|
-- ------------------------------
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.