{"id":34591508,"url":"https://github.com/ghmeier/go-service","last_synced_at":"2026-05-28T02:31:05.856Z","repository":{"id":77434173,"uuid":"86605047","full_name":"ghmeier/go-service","owner":"ghmeier","description":"HTTP service gateway in go.","archived":false,"fork":false,"pushed_at":"2017-05-09T02:59:31.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-14T19:01:19.089Z","etag":null,"topics":["gateway-microservice","golang","golang-tools","services"],"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/ghmeier.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":"2017-03-29T16:28:15.000Z","updated_at":"2017-05-20T20:49:17.000Z","dependencies_parsed_at":"2024-03-22T07:49:20.158Z","dependency_job_id":null,"html_url":"https://github.com/ghmeier/go-service","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ghmeier/go-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghmeier%2Fgo-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghmeier%2Fgo-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghmeier%2Fgo-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghmeier%2Fgo-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghmeier","download_url":"https://codeload.github.com/ghmeier/go-service/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghmeier%2Fgo-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33592074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["gateway-microservice","golang","golang-tools","services"],"created_at":"2025-12-24T10:51:46.791Z","updated_at":"2026-05-28T02:31:05.848Z","avatar_url":"https://github.com/ghmeier.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Service\n[![Build Status](https://travis-ci.org/ghmeier/go-service.svg?branch=master)](https://travis-ci.org/ghmeier/go-service)\n[![Coverage Status](https://coveralls.io/repos/github/ghmeier/go-service/badge.svg)](https://coveralls.io/github/ghmeier/go-service)\n[![Go Report Card](https://goreportcard.com/badge/github.com/ghmeier/go-service)](https://goreportcard.com/report/github.com/ghmeier/go-service)\n[![GoDoc](https://godoc.org/github.com/ghmeier/go-service?status.png)](http://godoc.org/github.com/ghmeier/service)\n\nHTTP service gateway in go. A simple library to send requests to external services without marshaling JSON yourself.\n\n## Installation\n\n```\ngo get github.com/ghmeier/go-service\n```\n\n## Examples\n\n*Note* All fields of the receiveing data type must be exported.\n\nSending one `GET` request:\n```\npackage example\n\nimport \"github.com/ghmeier/go-service\"\n\ntype Foo struct {\n    name string `json:\"name\"`\n}\n\nfunc Get() {\n    s := service.New()\n\n    var f Foo\n    err := s.Send(\u0026service.Request{\n        Method: \"GET\",\n        URL:    \"http://some.url.com/foo\",\n    }, \u0026f)\n}\n\n```\nThe default response will fill `f` with the object in the `data` field of the response and return an error if Response.`success` is `false`.\n\n\nSending one `POST` request:\n```\npackage example\n\nimport \"github.com/ghmeier/go-service\"\n\nfunc Post() {\n    s := service.New()\n\n    f := \u0026Foo{}\n    err := s.Send(\u0026service.Request{\n        Method: \"POST\",\n        URL:    \"http://some.url.com/foo\",\n        Data:   f,\n    }, nil)\n}\n\n```\n\nCheck out `examples.go` for an example of implementing a service gateway using `go-service`.\n\n## Custom Response\n\nIf you want to handle responses from services with different repsponse types, implement the `service.Responder` and `service.Response` interfaces.\n\n### Example Custom Responder/Response:\n```\ntype CustomResponder struct{}\n\n//Marshal should return a new response based on an http response. Usually this Unmarshals the body.\nfunc (c *CustomResponder) Marshal(r *http.Response) (service.Response, error) {\n    res := \u0026CustomResponse{}\n\n    res.OK = r.StatusCode == 200\n    res.Status = r.Status\n\n    return res\n}\n\ntype CustomResponse struct {\n    Status string `json:\"status\"`\n    OK     bool   `json:\"ok\"`\n}\n\n//Error should return an error based on the CustomResponse state\nfunc (c *CustomResponse) Error() error {\n    if !c.OK {\n        return fmt.Errorf(c.Status)\n    }\n\n    return nil\n}\n\n//Body should return a []byte that can be marshalled into the second argument of Service.Send()\nfunc (c *CustomResponse) Body() ([]byte, error) {\n    return json.Marshal(c)\n}\n```\n\nUsing Custom Responder:\n```\ns := service.NewCustom(\u0026CustomResponder{})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghmeier%2Fgo-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghmeier%2Fgo-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghmeier%2Fgo-service/lists"}