{"id":25130623,"url":"https://github.com/maxclaus/httpfake","last_synced_at":"2025-04-23T18:22:09.487Z","repository":{"id":53588114,"uuid":"97428249","full_name":"maxclaus/httpfake","owner":"maxclaus","description":"Httpfake – A Golang httptest wrapper for easily setting up a fake server","archived":false,"fork":false,"pushed_at":"2024-01-18T14:31:06.000Z","size":117,"stargazers_count":117,"open_issues_count":3,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-12T04:06:03.690Z","etag":null,"topics":["fake-server","fake-services","go","http","httptest"],"latest_commit_sha":null,"homepage":"","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/maxclaus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2017-07-17T02:44:55.000Z","updated_at":"2025-01-09T03:46:59.000Z","dependencies_parsed_at":"2024-06-18T16:41:16.587Z","dependency_job_id":"9611b869-da6d-46b4-a56e-7f507abfc477","html_url":"https://github.com/maxclaus/httpfake","commit_stats":{"total_commits":43,"total_committers":4,"mean_commits":10.75,"dds":0.2093023255813954,"last_synced_commit":"824787d29abaa2f70f84f6d9d49d670f235b41c5"},"previous_names":["maxclaus/httpfake"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxclaus%2Fhttpfake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxclaus%2Fhttpfake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxclaus%2Fhttpfake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxclaus%2Fhttpfake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxclaus","download_url":"https://codeload.github.com/maxclaus/httpfake/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250487795,"owners_count":21438663,"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":["fake-server","fake-services","go","http","httptest"],"created_at":"2025-02-08T13:17:43.329Z","updated_at":"2025-04-23T18:22:09.466Z","avatar_url":"https://github.com/maxclaus.png","language":"Go","readme":"httpfake\n========\n\n\u003cimg align=\"right\" width=\"125px\" src=\"https://raw.githubusercontent.com/maxcnunes/httpfake/master/logo/gopher-httpfake.png\"\u003e\n\n[![LICENSE](https://img.shields.io/badge/license-MIT-orange.svg)](LICENSE)\n[![Godocs](https://img.shields.io/badge/golang-documentation-blue.svg)](https://godoc.org/github.com/maxcnunes/httpfake)\n[![Build Status](https://travis-ci.org/maxcnunes/httpfake.svg?branch=master)](https://travis-ci.org/maxcnunes/httpfake)\n[![Coverage Status](https://coveralls.io/repos/github/maxcnunes/httpfake/badge.svg?branch=master)](https://coveralls.io/github/maxcnunes/httpfake?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/maxcnunes/httpfake)](https://goreportcard.com/report/github.com/maxcnunes/httpfake)\n\nhttpfake provides is a simple wrapper for [httptest](https://golang.org/pkg/net/http/httptest/) with a handful chainable API for setting up handlers to a fake server. This package is aimed to be used in tests where the original external server must not be reached. Instead is used in its place a fake server which can be configured to handle any request as desired.\n\n## Installation\n\n```\ngo get -u github.com/maxcnunes/httpfake\n```\n\nor\n\n```\ngovendor fetch github.com/maxcnunes/httpfake\n```\n\n\u003e If possible give preference for using vendor. This way the version is locked up as a dependency in your project.\n\n## Changelog\n\nSee [Releases](https://github.com/maxcnunes/httpfake/releases) for detailed history changes.\n\n## API\n\nSee [godoc reference](https://godoc.org/github.com/maxcnunes/httpfake) for detailed API documentation.\n\n## Assertions\n\nThere are built-in methods you can use to make assertions about requests to your HTTP handlers. The currently\nsupported assertions are:\n\n* Presence of query parameters\n* Query parameter and its expected value\n* Presence of HTTP headers\n* HTTP header and its expected value\n* The expected body of your request\n\n[WithTesting](https://godoc.org/github.com/maxcnunes/httpfake#WithTesting) **must** be provided as a server\noption when creating the test server if you intend to set request assertions. Failing to set the option\nwhen using request assertions will result in a panic.\n\n### Custom Assertions\n\nYou can also provide your own assertions by creating a type that implements the\n[Assertor interface](https://godoc.org/github.com/maxcnunes/httpfake#Assertor) or utilizing the\n[CustomAssertor function type](https://pkg.go.dev/github.com/maxcnunes/httpfake#CustomAssertor). The `Assertor.Log` method will be\ncalled for each assertion before it's processed. The `Assertor.Error` method will only be called if the\n`Assertor.Assert` method returns an error.\n\n## Examples\n\nFor a full list of examples please check out the [functional_tests folder](/functional_tests).\n\n```go\n// initialize the faker server\n// will bring up a httptest.Server\nfakeService := httpfake.New()\n\n// bring down the server once we\n// finish running our tests\ndefer fakeService.Close()\n\n// register a handler for our fake service\nfakeService.NewHandler().\n  Get(\"/users\").\n  Reply(200).\n  BodyString(`[{\"username\": \"dreamer\"}]`)\n\n// run a real http request to that server\nres, err := http.Get(fakeService.ResolveURL(\"/users\"))\n```\n\n## Contributing\n\nSee the [Contributing guide](/CONTRIBUTING.md) for steps on how to contribute to this project.\n\n## Reference\n\nThis package was heavily inspired on [gock](https://github.com/h2non/gock). Check that you if you prefer mocking your requests.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxclaus%2Fhttpfake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxclaus%2Fhttpfake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxclaus%2Fhttpfake/lists"}