Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

Web::API::Mock - It's new $module

SYNOPSIS

    $ 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

DESCRIPTION

Install

$ 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

Create API Documentation

# api.md

## GET /hello

+ Response 200 (text/plain)

        Hello World

Start Mock Server

$ run-api-mock --files api.md
HTTP::Server::PSGI: Accepting connections at http://0:5000

Options

  • 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

Switch to the Production API

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;
    }

LICENSE

Copyright (C) akihito.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

akihito takeda.akihito@gmail.com

About

Creates a mock server based on an API Blueprint

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages