Web::API::Mock - It's new $module
$ git clone git@github.com:takihito/Web-API-Mock.git
$ cpanm ./Web-API-Mock
or
$ cpanm Web::API::Mock
:
$ run-api-mock --help
Usage:
$ run-api-mock --files api.md --not-implemented-urls url.txt --port 8080
$ git clone git@github.com:takihito/Web-API-Mock.git
$ cpanm ./Web-API-Mock
or
$ cpanm Web::API::Mock
:
$ run-api-mock --help
Usage:
$ run-api-mock --files api.md --not-implemented-urls url.txt --port 8080
# api.md
## GET /hello
+ Response 200 (text/plain)
Hello World
$ run-api-mock --files api.md
HTTP::Server::PSGI: Accepting connections at http://0:5000
- files
- API Document Files.
$ run-api-mock --files api1.md --files api2.md
- not-implemented-urls
- Add "501 Not Implemented" info (Method and URL).
GET,/hello/hoge
POST,/hello/foo
-
port
-
server port
-
Other...
-
plackup options
By using nginx
see not-implemented-urls option.
$ run-api-mock --files api.md --not-implemented-urls url.txt --port 5001
upstream mock\_backend {
server 127.0.0.1:5001;
}
upstream prod\_backend {
server 127.0.0.1:5002;
}
server {
:
:
location ~ ^/ {
proxy_intercept_errors on;
proxy_pass http://mock_backend;
proxy_set_header Host $host;
}
error_page 501 =200 @prod;
location @prod {
proxy_pass http://prod_backend;
proxy_set_header Host $host;
}
Copyright (C) akihito.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
akihito takeda.akihito@gmail.com