{"id":19935937,"url":"https://github.com/gaelgirodon/liege","last_synced_at":"2025-10-17T13:21:45.210Z","repository":{"id":95469140,"uuid":"298903658","full_name":"GaelGirodon/liege","owner":"GaelGirodon","description":"HTTP stub server from plain files","archived":false,"fork":false,"pushed_at":"2025-02-09T22:05:58.000Z","size":59,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T16:07:05.965Z","etag":null,"topics":["api","http","http-server","json","mock","mock-api","mock-data","mock-server","mocking","mocking-server","mocking-utility","prototyping","rest-api","server","stub","stub-server","stubbing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GaelGirodon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-09-26T21:38:16.000Z","updated_at":"2025-02-09T22:06:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"8b471132-d86e-4d8b-b56c-2cb5f5df14f0","html_url":"https://github.com/GaelGirodon/liege","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaelGirodon%2Fliege","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaelGirodon%2Fliege/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaelGirodon%2Fliege/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GaelGirodon%2Fliege/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GaelGirodon","download_url":"https://codeload.github.com/GaelGirodon/liege/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252191034,"owners_count":21709000,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","http","http-server","json","mock","mock-api","mock-data","mock-server","mocking","mocking-server","mocking-utility","prototyping","rest-api","server","stub","stub-server","stubbing"],"created_at":"2024-11-12T23:22:41.674Z","updated_at":"2025-10-17T13:21:45.109Z","avatar_url":"https://github.com/GaelGirodon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# _Liège_\n\n[![release](https://img.shields.io/github/v/release/GaelGirodon/liege?style=flat-square)](https://github.com/GaelGirodon/liege/releases/latest)\n[![license](https://img.shields.io/github/license/GaelGirodon/liege?color=blue\u0026style=flat-square)](./LICENSE)\n[![build](https://img.shields.io/github/actions/workflow/status/GaelGirodon/liege/build.yml?branch=main\u0026style=flat-square)](https://github.com/GaelGirodon/liege/actions/workflows/build.yml)\n[![tests](https://img.shields.io/endpoint?style=flat-square\u0026url=https%3A%2F%2Fgist.githubusercontent.com%2FGaelGirodon%2Ffbde4d59b7dd3c4f2cc9c4fea3497ae1%2Fraw%2Fliege-go-tests.json)](https://github.com/GaelGirodon/liege/actions/workflows/build.yml)\n[![coverage](https://img.shields.io/endpoint?style=flat-square\u0026url=https%3A%2F%2Fgist.githubusercontent.com%2FGaelGirodon%2Ffbde4d59b7dd3c4f2cc9c4fea3497ae1%2Fraw%2Fliege-go-coverage.json)](https://github.com/GaelGirodon/liege/actions/workflows/build.yml)\n[![docker](https://img.shields.io/docker/image-size/gaelgirodon/liege?style=flat-square\u0026logo=docker\u0026logoColor=white)](https://hub.docker.com/r/gaelgirodon/liege)\n\nHTTP stub server from plain files\n\n## About\n\n_Liège_ is a static file server for tests with some special features\nto easily setup a stub server without requiring too much configuration:\n\n- Handle all HTTP methods\n  (static file servers usually handle `GET`/`HEAD` methods only)\n- Allow customizing request routing and response using the file name without\n  requiring a configuration file\n- Send the request body back in an HTTP header\n- Handle index files\n\n## Usage\n\n```shell\nliege [flags] \u003croot-dir\u003e\n```\n\n### Arguments\n\n| Argument     | Description                          | Environment variable | Configuration |\n| ------------ | ------------------------------------ | -------------------- | ------------- |\n| `\u003croot-dir\u003e` | Path to the server root directory    | `LIEGE_ROOT`         | `root`        |\n| `-p \u003cport\u003e`  | Port to listen on (default `3000`)   | `LIEGE_PORT`         |\n| `-c \u003ccert\u003e`  | Path to the TLS certificate PEM file | `LIEGE_CERT`         |\n| `-k \u003ckey\u003e`   | Path to the TLS private key PEM file | `LIEGE_KEY`          |\n| `-l \u003clat\u003e`   | Simulated response latency in ms     | `LIEGE_LATENCY`      | `latency`     |\n| `-v`         | Print the version number and exit    |\n| `-h`         | Print the help message and exit      |\n\n### Example\n\n```shell\n$ liege ./data/\n_________ __   _________________\n________ / /  /  _/ __/ ___/ __/\n_______ / /___/ // _// (_ / _/\n______ /____/___/___/\\___/___/\n\nHTTP server started on port 3000\n```\n\n### Configuration\n\nGiven the following file tree:\n\n```text\ndata/ -\u003e server root directory\n |-- items/\n |    |-- index.json\n |    |-- index__qs.json\n |    |-- 1__GET.json\n |-- admin/\n |    |-- index__403_l50 (empty file)\n```\n\nThe server will handle the following routes:\n\n| Method | Paths                                             | Query   | Response | Served file            | Latency |\n| ------ | ------------------------------------------------- | ------- | -------- | ---------------------- | ------- |\n| `*`    | `/items`\u003cbr\u003e`/items/index`\u003cbr\u003e`/items/index.json` |         | `200`    | `items/index.json`     | ~ 0 ms  |\n| `*`    | `/items`\u003cbr\u003e`/items/index`\u003cbr\u003e`/items/index.json` | `s[=*]` | `200`    | `items/index__qs.json` | ~ 0 ms  |\n| `GET`  | `/items/1`\u003cbr\u003e`/items/1.json`                     |         | `200`    | `items/1__GET.json`    | ~ 0 ms  |\n| `*`    | `/admin`\u003cbr\u003e`/admin/index`                        |         | `403`    |                        | ~ 50 ms |\n\nAnd send the following response with an optional additional latency:\n\n- **Status code**: `200` (default) or a custom code\n- **Headers**:\n  - `Content-Type`: determined from file content and extension,\n    e.g. `application/json; charset=utf-8`\n  - `X-Request-Body`: base64 encoded request body (only if body size \u003c= 4 KB)\n- **Body**: stub file contents\n\nRouting and response can be customized using the following file name syntax:\n\n```text\n\u003cpath\u003e[__\u003coptions\u003e][.\u003cext\u003e]\n```\n\n| Param     | Description                                     |\n| --------- | ----------------------------------------------- |\n| `path`    | File name, used in the URL path                 |\n| `options` | Additional routing and response configuration   |\n| `ext`     | File extension, helps to determine content type |\n\n`__\u003coptions\u003e` can be used to further customize request routing and response by\nappending a list of options, prefixed by `__` and separated by `_`, at the end\nof the file name:\n\n| Syntax           | Description                      | Default | Examples        |\n| ---------------- | -------------------------------- | ------- | --------------- |\n| `\u003cmethod\u003e`       | HTTP method                      | `*`     | `GET`           |\n| `q\u003ckey\u003e[=\u003cval\u003e]` | Required query parameter(s)      |         | `qerror=1`      |\n| `\u003ccode\u003e`         | Custom HTTP response status code | `200`   | `401`           |\n| `l\u003cx\u003e[-\u003cy\u003e]`     | Simulated response latency in ms | `0`     | `l40`, `l50-90` |\n\nFor example, the content of a file named `page__GET_qsearch_403_l250` will be\nsent with a `403` status code and at least 250 ms latency only for `GET`\nrequests on `/page` URL with a `search` query parameter.\n\nThe latency can be constant (`\u003cx\u003e`) or random between a range (`\u003cx\u003e-\u003cy\u003e`) and\ncan be defined globally (using the CLI or the environment variable) and at the\nroute level using the file name. The same syntax (`\u003cx\u003e[-\u003cy\u003e]`) is used in both\ncases. Latency defined at the file level overrides globally defined latency\nunless the latter is set to `-1` which totally disables latency.\n\nOn start-up, the server loads stub files in memory and build routes. To reload\nstub files from the root directory and update routes, call the\n`refresh` endpoint.\n\n### Management endpoints\n\nThe server provides the following management endpoints:\n\n| Method | Path              | Response | Description          |\n| ------ | ----------------- | -------- | -------------------- |\n| `GET`  | `/_liege/config`  | `200`    | Get configuration    |\n| `PUT`  | `/_liege/config`  | `204`    | Update configuration |\n| `POST` | `/_liege/refresh` | `204`    | Reload stub files    |\n| `GET`  | `/_liege/routes`  | `200`    | Get available routes |\n\n### TLS setup\n\nGenerate a self-signed X.509 TLS certificate or obtain a certificate from a CA,\nand start the server with `-c` and `-k` flags:\n\n```shell\n$ liege -c cert.pem -k key.pem ./data/\n```\n\n## License\n\n_Liège_ is licensed under the GNU General Public License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaelgirodon%2Fliege","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaelgirodon%2Fliege","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaelgirodon%2Fliege/lists"}