created_at2017-01-06 19:15:15.901676
updated_at2017-01-06 19:15:15.901676
descriptionEasy API mocking
Jakub Matraszek (jmatraszek)





Haxonite: Rock-solid API mocking for hackers

Haxonite is an easy-to-use API mocking server written in Rust.

Table of Contents


You can install Haxonite by running cargo install haxonite. Alternatively, you can clone the repository and compile (or download) the project yourself by running cargo build --release.

If you do not have Rust already installed, you can install it following these instructions.


$ haxonite --help
Haxonite 0.1.0 Jakub Matraszek
<jakub.matraszek@gmail.com> Easy API mocking

    haxonite [OPTIONS] [SUBCOMMAND]

        --help       Prints help information
    -V, --version    Prints version information

    -c, --config <FILE>    Sets a custom config file. Default: config.toml.
    -h, --host <HOST>      Run Haxonite on the host. Default: localhost.
    -p, --port <PORT>      Run Haxonite on the specified port. Default: 4000.

    help    Prints this message or the help of the given subcommand(s)
    new     Create new Haxonite project
$ haxonite new --help
haxonite-new 0.1.0
Jakub Matraszek <jakub.matraszek@gmail.com>
Create new Haxonite project

    haxonite new [FLAGS] <project_name>

    -f, --full       Use to create a project with full config.toml file
    -h, --help       Prints help information
    -V, --version    Prints version information

    <project_name>    Name of the project (will be used as a directory name)

You can find out more on using Haxonite.


Create a new project (you can also use --full option to generate full-blown config example):

$ haxonite new example
19:25:09 [INFO] haxonite::utils: Creating new project: example!

Following config.toml config file was created...

port = 4000
host = "localhost"

method = "GET"
path = "/"
status = 200
content_type = "application/json"
response = "responses/haxonite.json"

type = "static"
path = "/public"
response = "assets"

...along with an example JSON response:

$ cat responses/haxonite.json
  "haxonite": {
    "version": "{{ haxonite_version }}",
    "authors": "{{{ haxonite_authors }}}",
    "logo": "assets/haxonite.png"

Change directory to a newly generated project's directory and start Haxonite:

$ cd example && haxonite
19:29:03 [INFO] haxonite: Processing config!
19:29:03 [INFO] haxonite: Processing config for static: RequestConfig { type_: Some("static"), method: None, path: Some("/public"), responses: Some([ResponseConfig { content_type: None, status: None, response: Some("assets"), weight: None }]) }!
19:29:03 [INFO] haxonite: Mounting static for: /public using static type of handler.

19:29:03 [INFO] haxonite: Processing config for example_request: RequestConfig { type_: None, method: Some("GET"), path: Some("/"), responses: Some([ResponseConfig { content_type: Some("application/json"), status: Some(200), response: Some("responses/haxonite.json"), weight: None }]) }!
19:29:03 [INFO] haxonite: Defining route for: / using single type of handler.

And let's make a request to our mocked API and see what Haxonite returns:

$ curl http://localhost:4000
  "haxonite": {
    "version": "0.1.0",
    "authors": "Jakub Matraszek <jakub.matraszek@gmail.com>",
    "logo": "assets/haxonite.png"


This project is in early state of development. A lot of things may change. There are a couple of TODOs in the source code that are still to be fixed.

NOTE: Haxonite started as a project for my private use. I focused on simplicity, as I usually do not have to implement any sophisticated logic when mocking API. Hence it lacks the support, for example, for setting arbitrary HTTP headers in the response or for matching requests based on parsed parameters or request body. Mocking XMLRPC or SOAP APIs using Haxonite is not as easy as JSON's, but it's still possible (for example using chain request type). Also, there are no tests yet...


You can check out the changelog here.


  1. Fork the project.
  2. Create a topic branch.
  3. Implement your change.
  4. Add an entry to the changelog.
  5. Commit.
  6. Push to the topic branch.
  7. Create a pull request.

If you change anything regarding command-line options or config file format, please update README.md and USAGE.md files. Without this, the pull request will be rejected.

Please remember to keep your git commit message short and informative!

Questions and issues

Use Github's issue tracker for bug or feature requests. Drop me a line if you want to ask about anything that is not a bug/feature request.


If you like Haxonite — star this project and share this page. You can also follow me on Twitter.


You can check out the full license here. This project is licensed under the terms of the Apache 2.0 license.

Commit count: 40

cargo fmt