Browse Source

* StringToRouteMethod implemented

git-svn-id: trunk@35515 -
michael 8 years ago
parent
commit
d2b1232f33
1 changed files with 13 additions and 1 deletions
  1. 13 1
      packages/fcl-web/src/base/httproute.pp

+ 13 - 1
packages/fcl-web/src/base/httproute.pp

@@ -224,6 +224,9 @@ Function RouteMethodToString (R : TRouteMethod)  : String;
 // Shortcut for THTTPRouter.Service;
 // Shortcut for THTTPRouter.Service;
 Function HTTPRouter : THTTPRouter;
 Function HTTPRouter : THTTPRouter;
 
 
+Const
+  RouteMethodNames : Array[TRouteMethod] of String = ('','','GET','POST','PUT','DELETE','OPTIONS','HEAD','TRACE');
+
 implementation
 implementation
 
 
 uses strutils, typinfo;
 uses strutils, typinfo;
@@ -395,8 +398,17 @@ begin
 end;
 end;
 
 
 class function THTTPRouter.StringToRouteMethod(const S: String): TRouteMethod;
 class function THTTPRouter.StringToRouteMethod(const S: String): TRouteMethod;
-begin
 
 
+
+Var
+  MN : String;
+
+begin
+  Result:=High(TRouteMethod);
+  MN:=Uppercase(S);
+  While (Result>=Low(TRouteMethod)) and (RouteMethodNames[Result]<>MN) do
+    Result:=Pred(Result);
+  if Result=rmAll then Result:=rmUnknown;
 end;
 end;
 
 
 function THTTPRouter.RegisterRoute(const APattern: String;AData : Pointer;
 function THTTPRouter.RegisterRoute(const APattern: String;AData : Pointer;