Socket
Book a DemoInstallSign in
Socket

github.com/hlubek/logging-server

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/hlubek/logging-server

Source
Go
Version
v0.0.0-20130306224026-4ce9ee6135d8
Version published
Created
Source

Logging server Build Status

A logging server with simple mock handlers for quick HTTP API stubs, written in Google Go (golang). See all requests to an HTTP API and provide simple rules to respond to requests.

Installation

You need Google Go (1.0) in order to install this package (see http://golang.org/doc/install). After installing the Go SDK it should be as easy as:

go get github.com/chlu/logging-server

Running

Start a mock server just for logging:

logging-server

Start a mock server on a special address and port:

logging-server -address 0.0.0.0 -port 3000

Use a mock configuration for rules:

logging-server mock.json

Example mock configuration

[{
  "Method": "POST",
  "Path": "^/service/test/(.*)/action",
  "Response": {
    "Body": {"value": "9999999", "arbitrary_json": ["1234"]},
    "Defer": "375ms"
  }
}, {
  "Method": "GET",
  "Path": "/",
  "Response": {
    "ContentType": "text/html",
    "Body": "<html><body><h1>Hello world!</h1></body></html>"
  }
}]

Limitations

The logging server is most useful for JSON APIs right now. As you can see in the example mock configuration any text content type is also supported.

Some ideas for improvement:

  • Implement handling binary data in response
  • Support expressions in the response based on the request

FAQs

Package last updated on 06 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts