You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-29Lines changed: 30 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,48 +23,48 @@ Parameters:
23
23
24
24
For help type **erised -h**
25
25
26
-
Upon executing **erised** with no parameters, the server will listen on port **8080** for incoming http requests.
26
+
When executing **erised** with no parameters, the server will listen on port **8080** for incoming http requests.
27
27
28
-
When using the _-path_ option, please **EXERCISE GREAT CAUTION**choosing the path to search. See **Known Issues** for more information.
28
+
If you're using the _-path_ option, please **EXERCISE GREAT CAUTION**when setting the path to search. See **Known Issues** for more information.
29
29
30
30
The latest version is also available as a Docker image at [edaddario/erised](https://hub.docker.com/r/edaddario/erised).
31
31
32
-
To start the server in a docker container, with defaults values, exceute the following command:
32
+
To start the server in a docker container, with defaults values, execute the following command:
33
33
34
34
```sh
35
-
docker run --rm -p 8080:8080 edaddario/erised
35
+
docker run --rm -p 8080:8080 --name erised edaddario/erised
36
36
```
37
37
38
38
If you would like to return file based responses (_X-Erised-Response-File_ set) when using the docker image, you'll need to map the directory containing your local files and set the _-path_ option accordingly.
39
39
40
40
The following example maps the **/local_directory/response_files** directory in your local machine to **/files** in the docker image, and then sets the **-path** option:
41
41
42
42
```sh
43
-
docker run --rm -p 8080:8080 -v /local_directory/response_files:/files edaddario/erised -path ./files
|erised/info| GET |Returns miscellaneous information|
52
+
|erised/ip| GET |Returns the client IP|
53
+
|erised/shutdown| POST |Shutdowns the server|
54
54
55
55
Response behaviour is controlled via custom headers in the http request:
56
56
57
-
|Name|Purpose|
58
-
|--|--|
59
-
|X-Erised-Content-Type|Sets the response _Content-Type_. Valid values are **text** (default) for _text/plain_, **json** for _application/json_, **xml** for _application/xml_ and **gzip** for _application/octet-stream_. When using **gzip**, _Content-Encoding_ is also set to **gzip** and the response body is compressed accordingly.|
60
-
|X-Erised-Data|Returns the **same** value in the response body|
61
-
|X-Erised-Headers|Returns the value(s) in the response header. Values **must** be in a JSON key/value list|
62
-
|X-Erised-Location|Sets the response _Location_ to the new (redirected) URL or path, when 300 ≤ _X-Erised-Status-Code_ < 310|
63
-
|X-Erised-Response-Delay|Number of **milliseconds** to wait before sending response back to client|
64
-
|X-Erised-Response-File|Returns the contents of **file** in the response body. If present, _X-Erised-Data_ is ignored|
|X-Erised-Content-Type|Sets the response _Content-Type_. Valid values are **text** (default) for _text/plain_, **json** for _application/json_, **xml** for _application/xml_ and **gzip** for _application/octet-stream_. When using **gzip**, _Content-Encoding_ is also set to **gzip** and the response body is compressed accordingly.|
60
+
|X-Erised-Data|Returns the **same** value in the response body|
61
+
|X-Erised-Headers|Returns the value(s) in the response header. Values **must** be in a JSON key/value list|
62
+
|X-Erised-Location|Sets the response _Location_ to the new (redirected) URL or path, when 300 ≤ _X-Erised-Status-Code_ < 310|
63
+
|X-Erised-Response-Delay|Number of **milliseconds** to wait before sending response back to client|
64
+
|X-Erised-Response-File|Returns the contents of **file** in the response body. If present, _X-Erised-Data_ is ignored|
65
+
|X-Erised-Status-Code|Sets the HTTP Status Code|
66
66
67
-
By design, no validation is performed on _X-Erised-Data_ or _X-Erised-Location_.
67
+
No validation is performed on _X-Erised-Data_ or _X-Erised-Location_.
68
68
69
69
Valid _X-Erised-Status-Code_ values are:
70
70
```text
@@ -104,6 +104,7 @@ NetworkAuthenticationRequired or 511
104
104
Any other value will resolve to 200 (OK)
105
105
106
106
# Release History
107
+
* v0.6.7 - Improve server shutdown handling, and restrict allowed methods for _erised/headers_, _erised/ip_, _erised/info_ and _erised/shutdown_ routes
107
108
* v0.5.4 - Update dependencies
108
109
* v0.5.3 - Add file based responses
109
110
* v0.4.1 - Add route concurrency, update tests and dependencies
@@ -117,20 +118,20 @@ Any other value will resolve to 200 (OK)
117
118
* v0.0.1 - Initial release
118
119
119
120
# Known Issues
120
-
**erised**is full of bugs and "_...men have wasted away before it, not knowing if what they have seen is real, or even possible..._" so use it with caution for it gives no knowledge or truth.
121
+
**erised**may be full of bugs. Poeple "_... have wasted away before it, not knowing if what they have seen is real, or even possible..._" so, use it with caution for it gives no knowledge or truth.
121
122
122
123
Of all of its deficiencies, the most notable is:
123
124
* Using the _-path_ option could lead to significant security risks. By default, **erised** sets this option to point to the same directory in which is running and, when the _X-Erised-Response-File_ header is set, it will search recursively for a matching filename in the current directory and **all** subdirectories underneath, returning the contents of the first match. For example, if you set this value to your root directory (_-path=/_) **erised** will scan the entire volume for a match
124
125
* https protocol is not yet supported
125
126
126
-
I may or may not address this in a future release. Caveat Emptor
127
+
I may or may not address these issues in a future release. Caveat Emptor
127
128
128
129
# Motivation
129
-
When developing and testing REST based API clients, sooner or later I'd come across situations where I needed a quick and easy way to dynamically test endpoint's responses under different scenarios. Although there are many excellent frameworks and mock servers available, the time and effort required to configure them is sometimes not justified, specially if the application under test provides 10's or 100's of routes, so after some brief and unsuccessful googling I decided to create my own.
130
+
When developing and testing REST API clients, sooner or later I'd come across situations where I needed a quick and easy way to dynamically test endpoint's responses under different scenarios. Although there are many excellent frameworks and mock servers available, the time and effort required to configure them is sometimes not justified, specially if the application under test exposes many routes, so after some brief and unsuccessful googling I decided to create my own.
130
131
131
-
**erised** was inspired somewhat by [Kenneth Reitz's](https://kennethreitz.org/) HTTP Request & Response Service [httpbin.io](https://httpbin.org/) and it may offer similar functionality in future releases.
132
+
**erised** was inspired by [Kenneth Reitz's](https://kennethreitz.org/) HTTP Request & Response Service [httpbin.io](https://httpbin.org/) and it may offer similar functionality in future releases.
132
133
133
-
The typical use case is to get a response to an arbitrary http request where the content of the body has a predetermined value and your ability to control the server's behaviour is limited or non-existent.
134
+
The typical use case is to get a response to an arbitrary http request when your ability to control the server's behaviour is limited or non-existent.
134
135
135
136
Imagine you're developing some client for [api.chucknorris.io](https://api.chucknorris.io/) and want to test the **/jokes/random** path. You could certainly make live calls against the server:
0 commit comments