{"id":22572738,"url":"https://github.com/dmfed/quickstub","last_synced_at":"2025-07-06T16:33:05.851Z","repository":{"id":231941208,"uuid":"773445116","full_name":"dmfed/quickstub","owner":"dmfed","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-03T20:48:39.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T15:13:59.853Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmfed.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2024-03-17T17:20:55.000Z","updated_at":"2024-05-14T20:43:16.000Z","dependencies_parsed_at":"2024-04-07T01:08:21.005Z","dependency_job_id":"8b42fb4e-dee8-42d3-84e5-3131459c4b32","html_url":"https://github.com/dmfed/quickstub","commit_stats":null,"previous_names":["dmfed/quickstub"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmfed%2Fquickstub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmfed%2Fquickstub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmfed%2Fquickstub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmfed%2Fquickstub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmfed","download_url":"https://codeload.github.com/dmfed/quickstub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246049618,"owners_count":20715510,"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":[],"created_at":"2024-12-08T02:11:30.376Z","updated_at":"2025-03-28T14:45:07.452Z","avatar_url":"https://github.com/dmfed.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# quickstub - quick http server stub\n\nQuickstub is a HTTP server which can be configured in a very simple manner with a .yaml file.\n\nThe program is intended mainly for mocking some API responses when testing your applications.\n\nIn addition to primary configuration quickstab may be reconfigured on the fly using the \"magic endpoint\" (see below).\n\n## Quickstart\nInstall the binary\n```bash\ngo install github.com/dmfed/quickstub/cmd/quickstub@latest\n```\nGenerate the config\n```bash\nquickstub -sample \u003e myconfig.yaml\n```\nEdit the config as required (examples are included in the sample) then launch your server.\n\n```bash\nquickstub -conf myconfig.yaml\n```\n\n## Configuring the server\n\nLet's take a look at the sample configuration file.\n```yaml \nversion: 2\nlisten_addr: ':8080'\nmagic_endpoint: '/magic'\nendpoints:\n  # simple response with text body\n  'GET /hello':\n    code: 200\n    body: \"hello world\"\n\n  # responds with 201 code and text body\n  'POST /hello':\n    code: 201\n    body: \"created\"\n\n  # responds with 200 code a header and JSON body\n  'GET /hello':\n    code: 200\n    headers:\n        'Content-Type': 'application/json'\n    body: '{\"hello\": \"world\"}'\n\n  # redirects to /hello endpoint on the same host\n  'GET /redirect':\n    code: 301\n    headers: \n      'Connection': 'keep-alive'\n      'Location': '/hello'\n\n  # responds with 400 code \n  'GET /badrequest':\n    code: 400\n    body: 'These are not the droids you are looking for!'\n```\nThe first part configures the server itself.\n```yaml\nversion: 2\nlisten_addr: ':8080'\nmagic_endpoint: '/magic'\n```\n**version** is the version of API.\n\n**listen_addr** tells the server the hostname and port to listen on. It may take the following forms: \"172.0.0.1:8080\" or just \":8080\". This field is reauired and must not be empty.\n\n**magic_endpoint** is the path of endpoint where server accepts reconfigure requests (see below).\n\nThe **endpoints** part of the config is a configuration of responses of the server.\n\n### Plain text response\n```yaml\n'GET /hello':\n    code: 200\n    body: 'hello world'\n```\nThe above tells quickstub to repond with 200 and \"hello world\" text on endpoint \"/hello\".\n\n### JSON response\n```yaml \n'GET /hello':\n    code: 200\n    headers:\n        'Content-Type': 'application/json'\n    body: '{\"hello\": \"world\"}'\n```\nThis will instruct quickstub to repon with JSON in the body.\n\n### Response with file.\n```yaml \n'GET /config':\n    code: 200\n    headers: \n      'Content-Type': 'application/octet-stream'\n      'Content-Disposition': 'attachment; filename=myconfig.yaml'\n    body: '@myconfig.yaml'\n```\nThis tells the server to accept GET requests to \"/config\" endpoint and respond with provided headers and contents of file \"myconfig.yaml\" in response body. \n\nNote the \"@\" character. It tells qucikstub that the remaining part of the string is a local path to look for file. It may take form of \"@/home/myuser/somefile\" etc. If you want a string starting with \"@\" in response body, just escape it like this: \"\\\\@myresponse body\" for double-quoted strings and like this '\\@myresponse body' for single-quoted string. (Note that yaml distinguishes between double and single quotes for strings). \n\n**Note:** the actual contents of the file is preloaded into RAM on server start (or reconfiguration) so be midfull of what files to use. This program is just an http stub it is not intended to actually server huge files etc. So JSON is OK while ISO image is not. \n\n## Reconfigure endpoint or \"magic endpoint\"\nIf \"magic_endpoint\" is not empty in the config file then the server will listen to GET and PATCH requests on this endpoint. \n\n```yaml\nversion: 2\nlisten_addr: ':8080'\nmagic_endpoint: '/magic'\n```\nIn the above example doing\n```bash \ncurl -X GET localhost:8080/magic\n```\nwill return the current configuration of the server.\n\nTo reconfigure the server do.\n```bash\ncurl -X POST --data-binary '@my_new_config.yaml' localhost:8080/magic\n```\nThis will result in pushing your file \"my_new_config.yaml\" to the server. The server will validate the new config config and respond with 201 OK. Then quickstub will be restarted with new parameters.\n\nIf any validation errors occur quickstub will respond with 400 and error text in response body.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmfed%2Fquickstub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmfed%2Fquickstub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmfed%2Fquickstub/lists"}