Skip to content

Releases: NRException/mockapi

Release list

Release 0.0.1

Choose a tag to compare

@NRException NRException released this 24 Nov 20:06

MockAPI Releases!

Full features included at release are:

  • A Help menu! specify -h on the command line for help
  • Input file specification! specify -f on the command line to specify a configuration file path
  • Config file watching! specify -w on the command line to dynamically update the server configuration if the .yaml file changes.

For full documentation, refer to the wiki when available, for now, here is an example config file:

id: "primary_settings"
schema: "http://json-schema.org/draft-07/schema#"
description: "Basic Schema borrowed from URL in schema field..."
weblisteners:                             # N array of web listeners...
  - listenername: "Primary Listener"      # friendly name of the web listener
    listenerport: 8080                    # port to listen on
    onconnectkeepalive: true              # whether or not to immediately close connection when response given.
    enabletls: false                      # enable tls on the listener?
    #certdetails:                         # if enabletls is equal to true, provide the paths to the cert and key...
    #  certfile: cert.cer
    #  keyfile: key.cer
    contentbindings:                      # N array of static content bindings.
      - bindingpath: "/"                  # "directory" to bind to.
        responseheaders:                  # N array of headers to pass
          - headerkey: "content-type"     # Header Key
            headervalue: "text/plain"     # Header Value
        responsecode: 200                 # Response code to return
        responsebodytype: "inline"        # Type of content to return. use "responsebody" to return static content. Possible values are "static", "proxy", and "file"
        responsebody: "You're in the root" # Body of response to return, can be a file if responsebodytype is set to "file"

      - bindingpath: "/json"
        responseheaders:
          - headerkey: "content-type"
            headervalue: "text/json"
        responsecode: 200
        responsebodytype: "file"          
        responsebody: "build/test.json"

      - bindingpath: "/xml"
        responseheaders:
          - headerkey: "content-type"
            headervalue: "application/xml"
        responsecode: 200
        responsebodytype: "inline"        
        responsebody: "<thisisxml />"

      - bindingpath: "/txt"
        responseheaders:
          - headerkey: "content-type"
            headervalue: "text/text"
        responsebodytype: "file"        
        responsecode: 200
        responsebody: "build/test.txt"

      - bindingpath: "/html-inline"
        responseheaders:
          - headerkey: "content-type"
            headervalue: "text/html"
        responsebodytype: "inline"        
        responsecode: 200
        responsebody: "<h1>This is in-line html</h1>"

      - bindingpath: "/html"
        responseheaders:
          - headerkey: "content-type"
            headervalue: "text/html"
        responsebodytype: "file"        
        responsecode: 200
        responsebody: "build/test.html"