{"id":16475041,"url":"https://github.com/davidebianchi/go-jsonclient","last_synced_at":"2025-03-23T11:32:53.537Z","repository":{"id":38323471,"uuid":"248595553","full_name":"davidebianchi/go-jsonclient","owner":"davidebianchi","description":"Http client to handle json request and response written in go","archived":false,"fork":false,"pushed_at":"2024-11-25T03:21:20.000Z","size":65,"stargazers_count":5,"open_issues_count":3,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-02T00:24:13.290Z","etag":null,"topics":["http-client","json"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/davidebianchi/go-jsonclient","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/davidebianchi.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-19T20:11:21.000Z","updated_at":"2024-10-18T10:37:10.000Z","dependencies_parsed_at":"2024-06-19T06:15:44.794Z","dependency_job_id":"a1071ba5-f715-411c-8f54-26955ab2df2f","html_url":"https://github.com/davidebianchi/go-jsonclient","commit_stats":{"total_commits":55,"total_committers":6,"mean_commits":9.166666666666666,"dds":0.2909090909090909,"last_synced_commit":"ee93ca6c32417bec4668267610e09f4296c1a984"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidebianchi%2Fgo-jsonclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidebianchi%2Fgo-jsonclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidebianchi%2Fgo-jsonclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidebianchi%2Fgo-jsonclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidebianchi","download_url":"https://codeload.github.com/davidebianchi/go-jsonclient/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244297858,"owners_count":20430347,"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":["http-client","json"],"created_at":"2024-10-11T12:35:40.386Z","updated_at":"2025-03-23T11:32:53.155Z","avatar_url":"https://github.com/davidebianchi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Go Json Client\n\n[![Build Status][github-actions-svg]][github-actions]\n[![Go Report Card][go-report-card]][go-report-card-link]\n[![GoDoc][godoc-svg]][godoc-link]\n[![Coverage Status][coveralls-svg]][coveralls-link]\n\n\u003c/div\u003e\n\nGo Json Client simplify the http request in json.\n\nIt uses `net/http` core package as http client.\n\n## Install\n\nThis library require golang at version \u003e= 1.13\n\n```sh\ngo get -u github.com/davidebianchi/go-jsonclient\n```\n\n## Example usage\n\n### Make a request\n\nIf you want to create a json client to call a specific BaseUrl with default\nauthentication headers:\n\n```go\nfunc handleRequest () {\n  opts := jsonclient.Options{\n    BaseURL: \"http://base-url:8080/api/url/\",\n    Headers: jsonclient.Headers{\n      \"some\":  \"header\",\n      \"other\": \"value\",\n    },\n  }\n  client, err := jsonclient.New(opts)\n  if err != nil {\n    panic(\"Error creating client\")\n  }\n\n  var data = map[string]interface{}{\n    \"some\": \"json format\",\n    \"foo\":  \"bar\",\n    \"that\": float64(3),\n  }\n  req, err := client.NewRequest(http.MethodPost, \"my/path\", data)\n  if err != nil {\n    panic(\"Error creating request\")\n  }\n\n  type Response struct {\n    my string\n  }\n  v := Response{}\n  // server response is: {\"my\": \"data\"}\n  response, err := client.Do(req, \u0026v)\n  if err != nil {\n    panic(\"Error making request\")\n  }\n\n  if Response.my != \"data\" {\n    panic(\"response data is not mine\")\n  }\n}\n```\n\nThe library also check the status code of the request. If status code si not 2xx, it will return an `HTTPError`.\n\n## API\n\n### Accepted client options\n\nIn the `New` function, it is possible to add some options. None of the following options are required.\n\n* **BaseURL**: set the base url. BaseURL must be absolute and starts with `http` or `https` scheme. It must end with a trailing slash `/`. Example of valid BaseUrl: `\"http://base-url:8080/api/url/\"`\n* **Headers**: a map of headers to add to all the requests. For example, it could be useful when it is required an auth header.\n* **HTTPClient** (default to `http.DefaultClient`): an http client to use instead of the default http client. It could be useful for example for testing purpose.\n* **Host**: set the host in all client requests.\n\n## Versioning\n\nWe use [SemVer][semver] for versioning. For the versions available,\nsee the [tags on this repository](https://github.com/davidebianchi/go-jsonclient/tags).\n\n[github-actions]: https://github.com/davidebianchi/go-jsonclient/actions\n[github-actions-svg]: https://github.com/davidebianchi/go-jsonclient/workflows/Test%20and%20build/badge.svg\n[godoc-svg]: https://godoc.org/github.com/davidebianchi/go-jsonclient?status.svg\n[godoc-link]: https://pkg.go.dev/github.com/davidebianchi/go-jsonclient\n[go-report-card]: https://goreportcard.com/badge/github.com/davidebianchi/go-jsonclient\n[go-report-card-link]: https://goreportcard.com/report/github.com/davidebianchi/go-jsonclient\n[semver]: https://semver.org/\n[coveralls-svg]: https://coveralls.io/repos/github/davidebianchi/go-jsonclient/badge.svg?branch=master\n[coveralls-link]: https://coveralls.io/github/davidebianchi/go-jsonclient?branch=master\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidebianchi%2Fgo-jsonclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidebianchi%2Fgo-jsonclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidebianchi%2Fgo-jsonclient/lists"}