Create your own mock server with just a JSON file!

Gmocker

Run a blazing fast mock server in just seconds! 🚀

All you need is to make a json file that contains path and response mapping. See an example here.

Only json is supported for now, please create issues for bugs and new features.

Run

With defaults -

./mocker

Defaults: addr=localhost:7070 , file=mock.json

With custom flags -

./mocker -addr=<YOUR_HOST_AND_PORT> -file=<MOCK_JSON_FILE_LOCATION>

Sample mock.json file

{
  "path": {
    "jsonBody": ""
  }
}

These paths will be matched and the json will be sent.

Example -

{
  "/hello/worlds": {
    "message": "Hello worlds!",
    "data" : {
      "time": "now"
    },
    "worlds": [
      "cross origin world",
      "mars world",
      "moon world"
    ]
  }
}

If a request lands in the server in path /hello/worlds the nested json will be sent as response.

The request type [POST or GET] doesn't matter.

Build

For mac/linux -

go mod download
go build

For windows -

go mod download
GOOS=windows GOARCH=amd64 go build 

**If the build/binary doesn't work for you, you can do this -

  • Check your os and arch using this command - go env GOOS GOARCH
  • Use the output os and arch to build the binary - GOOS=<YOUR_OS> GOARCH=<YOUR_ARCH> go build
Owner
Ananto
Working with Vert.x, Webflux, Fiber. Learning Distributed systems. Building systems for 50M users.
Ananto
Similar Resources

Grpcmock - Mock grpc server with golang

grpcmock Mock gRPC server. Inspired by Prism. Add example responses to your prot

May 8, 2022

Test your code without writing mocks with ephemeral Docker containers 📦 Setup popular services with just a couple lines of code ⏱️ No bash, no yaml, only code 💻

Gnomock – tests without mocks 🏗️ Spin up entire dependency stack 🎁 Setup initial dependency state – easily! 🏭 Test against actual, close to product

Dec 29, 2022

Sql mock driver for golang to test database interactions

Sql driver mock for Golang sqlmock is a mock library implementing sql/driver. Which has one and only purpose - to simulate any sql driver behavior in

Dec 31, 2022

HTTP mock for Golang: record and replay HTTP/HTTPS interactions for offline testing

govcr A Word Of Warning I'm in the process of partly rewriting govcr to offer better support for cassette mutations. This is necessary because when I

Dec 28, 2022

Powerful mock generation tool for Go programming language

Summary Minimock generates mocks out of Go interface declarations. The main features of minimock are: It generates statically typed mocks and helpers.

Dec 17, 2022

Mock object for Go http.ResponseWriter

mockhttp -- Go package for unit testing HTTP serving Unit testing HTTP services written in Go means you need to call their ServeHTTP receiver. For thi

Sep 27, 2022

mockery - A mock code autogenerator for Golang

mockery - A mock code autogenerator for Golang

mockery - A mock code autogenerator for Golang

Jan 8, 2023

Completely type-safe compile-time mock generator for Go

Mockc Mockc is a completely type-safe compile-time mock generator for Go. You can use it just by writing the mock generators with mockc.Implement() or

Aug 25, 2022

Merge Mock - testing tool for the Ethereum Merge

MergeMock Experimental debug tooling, mocking the execution engine and consensus node for testing. work in progress Quick Start To get started, build

Oct 21, 2022
Comments
  • Bump github.com/valyala/fasthttp from 1.42.0 to 1.43.0

    Bump github.com/valyala/fasthttp from 1.42.0 to 1.43.0

    Bumps github.com/valyala/fasthttp from 1.42.0 to 1.43.0.

    Release notes

    Sourced from github.com/valyala/fasthttp's releases.

    v1.43.0

    • dbf457e Revert "feat: support mulit/range (#1398)" (#1446) (Erik Dubbelboer)
    • c50de95 client.go fix addMissingPort() (#1444) (Sergey Ponomarev)
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump github.com/valyala/fasthttp from 1.41.0 to 1.42.0

    Bump github.com/valyala/fasthttp from 1.41.0 to 1.42.0

    Bumps github.com/valyala/fasthttp from 1.41.0 to 1.42.0.

    Release notes

    Sourced from github.com/valyala/fasthttp's releases.

    v1.42.0

    • 4995135 feat: add ShutdownWithContext (#1383) (kinggo)
    • 7b3bf58 style: modify typo and remove repeated type conversions (#1437) (kinggo)
    • 8f43443 Wait for the response of pipelineWork in background and return it to pool (#1436) (Andy Pan)
    • c367454 Fix some potential pool leaks (#1433) (Andy Pan)
    • b32a3dd Use time.Until(deadline) instead of -time.Since(deadline) (#1434) (Andy Pan)
    • 8a60232 Assert with *net.TCPConn instead of *net.TCPListener in acceptConn() for TCP sockets (#1432) (Andy Pan)
    • c57a2ce Make sure nothing is nil in tmp slice (#1423) (hs son)
    • f095481 Request.SetTimeout (#1415) (brian-armstrong-discord)
    • c88dd5d fix form empty field error when used with pipe (#1417) (nick9822)
    • a468a7d feat: support mulit/range (#1398) (byene0923)
    • 3963a79 feat: add PeekKeys and PeekTrailerKeys (#1405) (kinggo)
    • eca86de fix: (#1410) (byene0923)
    • e214137 fix: ignore body should not set content-length of streaming (#1406) (byene0923)
    Commits
    • 4995135 feat: add ShutdownWithContext (#1383)
    • 7b3bf58 style: modify typo and remove repeated type conversions (#1437)
    • 8f43443 Wait for the response of pipelineWork in background and return it to pool (#1...
    • c367454 Fix some potential pool leaks (#1433)
    • b32a3dd Use time.Until(deadline) instead of -time.Since(deadline) (#1434)
    • 8a60232 Assert with *net.TCPConn instead of *net.TCPListener in acceptConn() for TCP ...
    • c57a2ce Make sure nothing is nil in tmp slice (#1423)
    • f095481 Request.SetTimeout (#1415)
    • c88dd5d fix form empty field error when used with pipe (#1417)
    • a468a7d feat: support mulit/range (#1398)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump github.com/valyala/fasthttp from 1.34.0 to 1.41.0

    Bump github.com/valyala/fasthttp from 1.34.0 to 1.41.0

    Bumps github.com/valyala/fasthttp from 1.34.0 to 1.41.0.

    Release notes

    Sourced from github.com/valyala/fasthttp's releases.

    v1.41.0

    • 128e9b3 optimize: adjust the behavior of PeekAll based on VisitAll (#1403) (kinggo)
    • 2c8ce3b feat: add header.PeekAll (#1394) (kinggo)
    • d404f2d make RequestCtx's userdata accept keys that are of type: interface{} (#1387) (pj)
    • bcf7e8e test: merge test in adaptor_test.go (#1381) (kinggo)
    • 31fdc79 resolve CVE-2022-27664 (#1377) (Craig O'Donnell)
    • 40eec0b byte to string unsafe conversion in fasthttpadaptor ConvertRequest method (#1375) (Emre Savcı)
    • a696949 Deprecate Go 1.15 (#1379) (Aoang)

    v1.40.0

    • 2f1e949 Improve isTLSAlready check (Erik Dubbelboer)
    • 404c8a8 Chore (#1365) (tyltr)
    • 79ccfff Don't use tls ClientSessionCache (Erik Dubbelboer)
    • 28bec71 Fix "use of closed network connection" error check (Erik Dubbelboer)
    • 3b147b7 Fix(server): reset maxRequestBodySize to the server's config (#1360) (Geralt X Li)
    • af94725 Reduce slice growth in adaptor (#1356) (Qing Moy)

    v1.39.0

    • ea60524 Add Go 1.19 Support (#1355) (Aoang)
    • a5f448f Improve Client timeout (#1346) (Erik Dubbelboer)
    • 42f83c6 Prevent overflow and panic on large HTTP responses (#1351) (mathew)
    • f3513cc Introduce FS.CompressRoot (#1331) (mojatter)
    • c94be05 use timeout insteadof read/writetimeout when timeout lower than read/… (#1336) (fare83)
    • b23c5e9 Close new connections after 5s in closeIdleConns (Erik Dubbelboer)
    • 5b0cbf2 Fix apparent documentation typo (#1330) (kayos)

    v1.38.0

    • 16d30c4 Support AIX SO_REUSEADDR and SO_REUSEPORT (#1328) (zhangyongding)
    • bc24f9d Consolidate TCPKeepalive in server.Serve (#1320) (#1324) (Y.Horie)
    • 8a32089 Add ConnPoolStrategy field to client (#1317) (Thearas)
    • 35aca7b BodyDecoded() for request and responses (#1308) (Sergey Ponomarev)
    • 66cd502 header.go Referer() optimize (#1313) (Sergey Ponomarev)
    • c9f43ea Response.ContentEncoding(): store as field and avoid using Header.SetCanonical() (#1311) (Sergey Ponomarev)
    • de18824 Optimize server connection close logic (#1310) (Sergey Ponomarev)

    v1.37.0

    • 66bc61e Add an option to allow empty root in the fsHandler (#1299) (RW)
    • 9961079 Fix userdata re-use after Remove (Erik Dubbelboer)

    v1.36.0

    • 7cc6f4c Fix DoTimeout Streaming body bug (Erik Dubbelboer)
    • 9a0b4d0 optimize (#1275) (tyltr)
    • e3d2512 optimize (#1272) (tyltr)
    • b40b5a4 Update tlsClientHandshake (#1263) (Mikhail Faraponov)
    • c7576cc Added Windows support and removed some panics (#1264) (Mauro Leggieri)
    • f0e1be5 add nil check of req.body and resp.body on ReleaseBody (#1266) (zzzzwc)

    v1.35.0

    • 7a5afdd Use %v for errors and %q for strings (#1262) (Erik Dubbelboer)
    • e4a541f support adding/removing clients from LBClient (#1243) (Cam Sweeney)

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump github.com/valyala/fasthttp from 1.24.0 to 1.34.0

    Bump github.com/valyala/fasthttp from 1.24.0 to 1.34.0

    Bumps github.com/valyala/fasthttp from 1.24.0 to 1.34.0.

    Release notes

    Sourced from github.com/valyala/fasthttp's releases.

    v1.34.0

    • 59f94a3 Update github.com/klauspost/compress (#1237) (Mikhail Faraponov)
    • 62c15a5 Don't reset RequestCtx.s (#1234) (Erik Dubbelboer)
    • 7670c6e Fix windows tests (#1235) (Erik Dubbelboer)
    • f54ffa1 feature: Keep the memory usage of the service at a stable level (#1216) (Rennbon)
    • 15262ec Warn about unsafe ServeFile usage (#1228) (Erik Dubbelboer)
    • 1116d03 Fix panic while reading invalid trailers (Erik Dubbelboer)
    • 856ca8e Update dependencies (#1230) (Mikhail Faraponov)
    • 6b5bc7b Add windows support to normalizePath (Erik Dubbelboer)
    • f0b0cfe Don't log ErrBadTrailer by default (Erik Dubbelboer)
    • 6937fee fix: (useless check), skip Response body if http method HEAD (#1224) (Pavel Burak)
    • b85d2a2 Fix http proxy behavior (#1221) (Aoang)
    • ad8a07a RequestHeader support set no default ContentType (#1218) (Jack.Ju)
    • c94581c support configure HostClient (#1214) (lin longhjui)
    • 632e222 Client examples (#1208) (Sergey Ponomarev)
    • 6a3cc23 uri_test.go use example.com for clearness (#1212) (Sergey Ponomarev)
    • 9d665e0 Update dependencies (#1204) (Mikhail Faraponov)
    • 8d7953e Fix scheme check for not yet parsed requests (#1203) (ArminBTVS)

    v1.33.0

    • 61aa8b1 remove redundant code (#1202) (tyltr)
    • 4369776 fix(hijack): reuse RequestCtx (#1201) (Sergio VS)
    • 2aca3e8 fix(hijack): reset userValues after hijack handler execution (#1199) (Sergio VS)
    • 9123060 Updated dependencies (#1194) (Mikhail Faraponov)

    v1.32.0

    • 7eeb00e Make tests less flaky (#1189) (Erik Dubbelboer)
    • d19b872 Update tcpdialer.go (#1188) (Mikhail Faraponov)
    • c727b99 Release UseHostHeader in ReleaseRequest() (#1185) (Tolyar)
    • 6c0518b Fix UseHostHeader for DoTimeout + tests (#1184) (Tolyar)
    • 6b55811 Add MaxIdleWorkerDuration to Server. (#1183) (Kilos Liu)
    • 4517204 Allow to set Host header for Client (#1169) (Tolyar)
    • 258a4c1 fix: reset response after reset user values on keep-alive connections (#1176) (Sergio VS)
    • e9db537 Use %w to wrap errors (#1175) (Erik Dubbelboer)
    • 7db0597 Fix bad request trailer panic (Erik Dubbelboer)
    • 4aadf9a Fix parseTrailer panic (Erik Dubbelboer)
    • da7ff7a Add trailer support (#1165) (ichx)
    • 017f0aa fix: reset request after reset user values on keep-alive connections (#1162) (Sergio VS)
    • 3b117f8 feat: close idle connections when server shutdown (#1155) (ichx)
    • a94a2c3 Remove redundant code (#1154) (ichx)
    • f7c354c Fix race condition in Client.mCleaner (Erik Dubbelboer)
    • c078a9d Add string and bytes buffer convert trick in README (#1151) (ichx)
    • 3ff6aaa uri: isHttps() and isHttp() (#1150) (Sergey Ponomarev)
    • 8febad0 http.go: Request.SetURI() (Fix #1141) (#1148) (Sergey Ponomarev)
    • 2ca01c7 fix: Status Line parsing and writing (#1135) (Shivansh Vij)
    • 931d0a4 Fix lint (Erik Dubbelboer)
    • d613502 use sync.map is better (#1145) (halst)
    • c15e642 Don't run all race tests on windows (#1143) (Erik Dubbelboer)
    • 6006c87 chore (#1137) (tyltr)
    • 6d4db9b Fix race condition in getTCPAddrs (Erik Dubbelboer)

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

CLI tool to mock TCP connections. You can use it with Detox, Cypress or any other framework to automatically mock your backend or database.

Falso It is a CLI that allows you to mock requests/responses between you and any server without any configuration or previous knowledge about how it w

Sep 23, 2022
Just Dance Unlimited mock-up server written on Golang and uses a popular Gin framework for Go.

BDCS Just Dance Unlimited mock-up server written on Golang and uses a popular Gin framework for Go. Features Security Authorization works using UbiSer

Nov 10, 2021
Vault mock - Mock of Hashicorp Vault used for unit testing

vault_mock Mock of Hashicorp Vault used for unit testing Notice This is a person

Jan 19, 2022
Mock-the-fck - Mock exercise for human

Mock the fck Originally, Mockery-example Example case for mockery issue #128 fil

Jan 21, 2022
A simple mock server configurable via JSON, built using GoLang.
A simple mock server configurable via JSON, built using GoLang.

GoMock Server A simple mock server configurable via JSON, built using GoLang. How To A file name endpoint.json must be placed in the context root, wit

Nov 19, 2022
A go server which will respond with data to mock a server!

Mocker A go program which will respond with data to mock a server; mainly useful while developing a frontend application, whose backend is not running

Jan 5, 2023
ESME is a go library that allows you to mock a RESTful service by defining the configuration in json format

ESME is a go library that allows you to mock a RESTful service by defining the configuration in json format. This service can then simply be consumed by any client to get the expected response.

Mar 2, 2021
Dec 8, 2022
mock server to aid testing the jaguar-java client API

stripe-mock stripe-mock is a mock HTTP server that responds like the real Stripe API. It can be used instead of Stripe's test mode to make test suites

Dec 24, 2021
Mockserver - Super slim & blazing fast mock server to replace the Java/NPM counterpart mockserver

Gmocker Run a blazing fast mock server in just seconds! ?? All you need is to ma

Jan 30, 2022