浏览代码

Code formatting added / Fixed bug with authentication

Simon Grossenbacher 9 年之前
父节点
当前提交
00b0a8bb8c
共有 7 个文件被更改,包括 97 次插入48 次删除
  1. 3 3
      AppConfig.json
  2. 二进制
      RESTDebugger.exe
  3. 13 2
      Test-Config.rdproj
  4. 17 17
      prj/RESTDebugger.dproj
  5. 6 6
      prj/RESTDebugger.stat
  6. 5 19
      src/_frmMain.dfm
  7. 53 1
      src/_frmMain.pas

+ 3 - 3
AppConfig.json

@@ -5,12 +5,12 @@
 	},
 	"Project": {
 		"AutoOpenLastUsed": true,
-		"LastUsed": "C:\\dev\\Simnet\\SmartHome\\SmartHomeService\\SmartHome.rdproj",
+		"LastUsed": "C:\\dev\\RESTDebugger\\Test-Config.rdproj",
 		"AutoSaveProject": true
 	},
 	"MainWindowPos": {
-		"Left": 912,
-		"Top": 362,
+		"Left": 1160,
+		"Top": 319,
 		"Width": 720,
 		"Height": 930,
 		"StayOnTop": false

二进制
RESTDebugger.exe


+ 13 - 2
Test-Config.rdproj

@@ -1,7 +1,7 @@
 {
 	"Presets": {
-		"Presets": "Default\r\nMERP\r\nTest IP\r\nTest Headers\r\nSample POST\r\n",
-		"LastUsed": 1
+		"Presets": "Default\r\nMERP\r\nTest IP\r\nTest Headers\r\nSample POST\r\nZWave direkt\r\n",
+		"LastUsed": 5
 	},
 	"Preset_0": {
 		"BaseURL": "",
@@ -57,5 +57,16 @@
 		"UseBasicAuth": false,
 		"AuthUsername": "ThPDSfhDWlUyuqX9fYp7BA==",
 		"AuthPassword": "ThPDSfhDWlUyuqX9fYp7BA=="
+	},
+	"Preset_5": {
+		"BaseURL": "http://192.168.30.60:8083/ZAutomation/api/v1/devices",
+		"Method": 0,
+		"URLParams": "",
+		"PostData": "",
+		"ExtraHeaders": "",
+		"PostDataContentType": "application/json",
+		"UseBasicAuth": true,
+		"AuthUsername": "lhmg2d7oD+XEqAb53vskWA==",
+		"AuthPassword": "Dzqw3DbtjDmRXWKn2o/GxRVRrxwhHqldEiLV9rFFEU8="
 	}
 }

+ 17 - 17
prj/RESTDebugger.dproj

@@ -174,27 +174,12 @@
                         <Overwrite>true</Overwrite>
                     </Platform>
                 </DeployFile>
-                <DeployClass Name="DependencyModule">
-                    <Platform Name="Win32">
-                        <Operation>0</Operation>
-                        <Extensions>.dll;.bpl</Extensions>
-                    </Platform>
+                <DeployClass Name="ProjectiOSDeviceResourceRules">
                     <Platform Name="iOSDevice64">
                         <Operation>1</Operation>
-                        <Extensions>.dylib</Extensions>
-                    </Platform>
-                    <Platform Name="OSX32">
-                        <RemoteDir>Contents\MacOS</RemoteDir>
-                        <Operation>1</Operation>
-                        <Extensions>.dylib</Extensions>
                     </Platform>
                     <Platform Name="iOSDevice32">
                         <Operation>1</Operation>
-                        <Extensions>.dylib</Extensions>
-                    </Platform>
-                    <Platform Name="iOSSimulator">
-                        <Operation>1</Operation>
-                        <Extensions>.dylib</Extensions>
                     </Platform>
                 </DeployClass>
                 <DeployClass Name="ProjectOSXResource">
@@ -545,12 +530,27 @@
                         <Operation>1</Operation>
                     </Platform>
                 </DeployClass>
-                <DeployClass Name="ProjectiOSDeviceResourceRules">
+                <DeployClass Name="DependencyModule">
+                    <Platform Name="Win32">
+                        <Operation>0</Operation>
+                        <Extensions>.dll;.bpl</Extensions>
+                    </Platform>
                     <Platform Name="iOSDevice64">
                         <Operation>1</Operation>
+                        <Extensions>.dylib</Extensions>
+                    </Platform>
+                    <Platform Name="OSX32">
+                        <RemoteDir>Contents\MacOS</RemoteDir>
+                        <Operation>1</Operation>
+                        <Extensions>.dylib</Extensions>
                     </Platform>
                     <Platform Name="iOSDevice32">
                         <Operation>1</Operation>
+                        <Extensions>.dylib</Extensions>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                        <Extensions>.dylib</Extensions>
                     </Platform>
                 </DeployClass>
                 <ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>

+ 6 - 6
prj/RESTDebugger.stat

@@ -1,10 +1,10 @@
 [Stats]
-EditorSecs=4542
-DesignerSecs=2244
-InspectorSecs=1106
-CompileSecs=127363
-OtherSecs=1443
+EditorSecs=5382
+DesignerSecs=2308
+InspectorSecs=1132
+CompileSecs=144004
+OtherSecs=1440
 StartTime=27.10.2016 18:27:37
 RealKeys=0
 EffectiveKeys=0
-DebugSecs=3428
+DebugSecs=4087

+ 5 - 19
src/_frmMain.dfm

@@ -31,7 +31,7 @@ object frmMain: TfrmMain
     BevelOuter = bvNone
     Color = clWhite
     ParentBackground = False
-    TabOrder = 4
+    TabOrder = 3
     object Label1: TLabel
       Left = 25
       Top = 31
@@ -223,10 +223,6 @@ object frmMain: TfrmMain
     object tabHeaders: TcxTabSheet
       Caption = 'Response Headers'
       ImageIndex = 1
-      ExplicitLeft = 0
-      ExplicitTop = 0
-      ExplicitWidth = 0
-      ExplicitHeight = 0
       object EditorHeaders: TBCEditor
         Left = 0
         Top = 0
@@ -333,7 +329,7 @@ object frmMain: TfrmMain
     Height = 372
     Align = alTop
     BevelOuter = bvNone
-    TabOrder = 3
+    TabOrder = 1
     object Label2: TLabel
       Left = 8
       Top = 16
@@ -592,10 +588,6 @@ object frmMain: TfrmMain
       object cxTabSheet2: TcxTabSheet
         Caption = 'Extra Headers'
         ImageIndex = 1
-        ExplicitLeft = 0
-        ExplicitTop = 0
-        ExplicitWidth = 0
-        ExplicitHeight = 0
         object EditorExtraHeaders: TBCEditor
           Left = 0
           Top = 31
@@ -717,10 +709,6 @@ object frmMain: TfrmMain
       object cxTabSheet3: TcxTabSheet
         Caption = 'Authentication'
         ImageIndex = 3
-        ExplicitLeft = 0
-        ExplicitTop = 0
-        ExplicitWidth = 0
-        ExplicitHeight = 0
         object Label9: TLabel
           Left = 15
           Top = 47
@@ -757,10 +745,6 @@ object frmMain: TfrmMain
       object tabPostData: TcxTabSheet
         Caption = 'Post Data'
         ImageIndex = 2
-        ExplicitLeft = 0
-        ExplicitTop = 0
-        ExplicitWidth = 0
-        ExplicitHeight = 0
         object EditorPostData: TBCEditor
           Left = 0
           Top = 46
@@ -1177,7 +1161,9 @@ object frmMain: TfrmMain
       Caption = '-'
     end
     object pbtnFormatCode: TMenuItem
-      Caption = 'Format Code'
+      Caption = 'Format Code && Syntax check'
+      ShortCut = 41030
+      OnClick = pbtnFormatCodeClick
     end
   end
   object cxImageList: TcxImageList

+ 53 - 1
src/_frmMain.pas

@@ -116,6 +116,7 @@ type
     procedure tbbtnAutoOpenLastUsedClick(Sender: TObject);
     procedure dxBarButton2Click(Sender: TObject);
     procedure tbbtnAutoSaveProjectClick(Sender: TObject);
+    procedure pbtnFormatCodeClick(Sender: TObject);
   private
     FMainConfig: TJSONConfig;
     FProjectConfig: TJSONConfig;
@@ -144,7 +145,7 @@ implementation
 
 {$R *.dfm}
 
-uses System.NetEncoding, System.UITypes, _EncryptStr;
+uses System.NetEncoding, System.UITypes, _EncryptStr, JsonDataObjects;
 
 procedure TfrmMain.tbbtnRunClick(Sender: TObject);
 begin
@@ -541,6 +542,56 @@ begin
   EditorContent.PasteFromClipboard;
 end;
 
+procedure TfrmMain.pbtnFormatCodeClick(Sender: TObject);
+var
+  ja: TJsonArray;
+  jo: TJsonObject;
+begin
+  if EditorContent.Lines.Count > 0 then
+  begin
+    if Length(EditorContent.Lines[0]) > 0 then
+    begin
+      if EditorContent.Lines[0][1] = '{' then
+      begin
+        jo := TJsonObject.Create;
+        try
+          try
+            jo.FromJSON(EditorContent.Lines.Text);
+          except
+            on E: Exception do
+            begin
+              MessageDlg(E.Message, mtError, [mbOK], 0);
+            end;
+          end;
+          EditorContent.Lines.Clear;
+          jo.SaveToLines(EditorContent.Lines);
+        finally
+          jo.Free;
+        end;
+      end
+      else
+      if EditorContent.Lines[0][1] = '[' then
+      begin
+        ja := TJsonArray.Create;
+        try
+          try
+            ja.FromJSON(EditorContent.Lines.Text);
+          except
+            on E: Exception do
+            begin
+              MessageDlg(E.Message, mtError, [mbOK], 0);
+            end;
+          end;
+          EditorContent.Lines.Clear;
+          ja.SaveToLines(EditorContent.Lines);
+        finally
+          ja.Free;
+        end;
+      end;
+    end;
+  end;
+end;
+
 procedure TfrmMain.Run;
 var
   dmy: string;
@@ -557,6 +608,7 @@ begin
     begin
       HTTP.Request.Username := edtAuthUsername.Text;
       HTTP.Request.Password := edtAuthPassword.Text;
+      HTTP.Request.BasicAuthentication := True;
     end;
 
     if comboMethod.ItemIndex = 0 then