Skip to content

Commit 67fdf5e

Browse files
ADD: made view optional in setdir
1 parent 6090282 commit 67fdf5e

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/rest.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ This is the CopyCommander2 Rest API Documentation.
44

55
CopyCommander REST API only supports JSON as data format. To see how to enable / setup the REST functionality visit the [rest api](how_to_use.md#rest-api) section in the how_to_use document.
66

7-
There are 2 kinds of paths supported by CopyCommander2
7+
There are 2 kinds of paths supported by CopyCommander2.
88

99
#### Normal paths:
1010
Normal paths are always available and can be used to get status, start jobs, ...
1111

1212
#### Zombie paths:
1313
Zombie paths are used to control the application (visible to the user), to enable these paths you need to pass in a extra command line paramter.
1414

15+
## List of available methods / paths
1516
| Method | Overview | Kind | Description
1617
| --- | --- | --- | --- |
1718
| GET | [/API/status](#get-apistatus) | normal | get current state of application
19+
| GET | [/API/view/list](#get-apiviewlist) | normal | get list of content from a spezific view
1820
| POST | [/API/zombie/setdir](#post-apizombiesetdir) | zombie | set directory path for left or right view
1921

2022
## GET /API/status
@@ -27,6 +29,10 @@ Returns the current status of the application.
2729
**Path:** `/API/status`
2830
**Content-Type:** Not applicable
2931

32+
### Query Parameters
33+
34+
none
35+
3036
### Response
3137

3238
**Content-Type:** `application/json`
@@ -40,6 +46,12 @@ Returns the current status of the application.
4046
| `LeftDir` | string | Path to the left directory |
4147
| `RightDir` | string | Path to the right directory |
4248

49+
### Example Request
50+
51+
```
52+
GET /API/status
53+
```
54+
4355
### Example Response
4456

4557
```json
@@ -111,11 +123,11 @@ Sets the directory path for either the left or right view.
111123
**Path:** `/API/zombie/setdir`
112124
**Content-Type:** `application/json`
113125

114-
### Request Schema
126+
### Post Request Schema
115127

116128
| Field | Type | Required | Description |
117129
|-------|------|----------|-------------|
118-
| `view` | string | Yes | Must be either "left" or "right" |
130+
| `view` | string | No | Must be either "left" or "right", default (left) |
119131
| `dir` | string | Yes | Directory path to set |
120132

121133
### Example Request
@@ -127,8 +139,8 @@ Sets the directory path for either the left or right view.
127139
}
128140
```
129141

130-
### Response
142+
### Example Response
131143

132144
**Status Codes:**
133145
- `204 No Content` - Directory successfully set
134-
- `422 Unprocessable Entity` - Invalid request data / target dir, does not exist.
146+
- `422 Unprocessable Entity` - Invalid request data / target dir, does not exist.

src/urestapi.pas

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,20 @@
146146
Const aContent: TJSONObj): Boolean;
147147
Var
148148
jv, jd: TJSONValue;
149-
dir: String;
149+
view, dir: String;
150150
Begin
151151
result := false;
152152
Try
153+
view := 'left';
153154
jv := aContent.FindPath('view') As TJSONValue;
154-
If Not assigned(jv) Then exit;
155+
If assigned(jv) Then Begin
156+
view := trim(jv.Value);
157+
End;
155158
jd := aContent.FindPath('dir') As TJSONValue;
156159
If Not assigned(jd) Then exit;
157160
dir := jd.Value;
158161
If Not DirectoryExists(dir) Then exit;
159-
Case lowercase(trim(jv.Value)) Of
162+
Case lowercase(view) Of
160163
'left': form1.LoadDir(dir, form1.fLeftView);
161164
'right': form1.LoadDir(dir, form1.fRightView);
162165
Else Begin

0 commit comments

Comments
 (0)