{"id":43515441,"url":"https://github.com/zspkg/jac","last_synced_at":"2026-02-03T13:40:00.256Z","repository":{"id":161508321,"uuid":"636192994","full_name":"zspkg/jac","owner":"zspkg","description":"Simple JSON API service connector (JAC) buildbase","archived":false,"fork":false,"pushed_at":"2023-12-19T20:08:39.000Z","size":3225,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2023-12-20T15:17:43.776Z","etag":null,"topics":["api","golang","jwt"],"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/zspkg.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}},"created_at":"2023-05-04T10:07:29.000Z","updated_at":"2023-11-16T15:00:46.000Z","dependencies_parsed_at":"2023-12-20T11:59:41.963Z","dependency_job_id":"768fa7af-10f7-47c7-97aa-3370281ad889","html_url":"https://github.com/zspkg/jac","commit_stats":null,"previous_names":[],"tags_count":3,"template":null,"template_full_name":null,"purl":"pkg:github/zspkg/jac","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspkg%2Fjac","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspkg%2Fjac/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspkg%2Fjac/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspkg%2Fjac/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zspkg","download_url":"https://codeload.github.com/zspkg/jac/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zspkg%2Fjac/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29046676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T10:09:22.136Z","status":"ssl_error","status_checked_at":"2026-02-03T10:09:16.814Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api","golang","jwt"],"created_at":"2026-02-03T13:39:59.247Z","updated_at":"2026-02-03T13:40:00.244Z","avatar_url":"https://github.com/zspkg.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :jack_o_lantern: JAC — JSON API service connector building base\n[![Go Reference](https://pkg.go.dev/badge/github.com/zspkg/jac#section-readme.svg)](https://pkg.go.dev/github.com/zspkg/jac#section-readme)\n[![codecov](https://codecov.io/github/zspkg/jac/branch/main/graph/badge.svg?token=JO5Qd0Zw20)](https://codecov.io/github/zspkg/jac)\n[![Go Report Card](https://goreportcard.com/badge/github.com/zspkg/jac)](https://goreportcard.com/report/github.com/zspkg/jac)\n\nJAC is a building base for custom JSON API service connectors. \n\n## Usage example\n\n```go\npackage examples\n\nimport (\n\t\"encoding/json\"\n\t\"github.com/zspkg/jac\"\n)\n\n// FooServiceConnector is your custom service connector\ntype FooServiceConnector struct {\n\tjac.Jac\n\tcreateFooEndpoint string\n}\n\n// Foo is the service object\ntype Foo struct {\n\tbar int\n}\n\n// FooCreateResponse is the service response when creating Foo\ntype FooCreateResponse struct {\n\tid  int\n\tbar int\n}\n\n// NewFooServiceConnector is your custom connector to FooService where\n// you can define your own data transformations and operations and\n// then use jac.Jac's methods to easily send POST/GET/DELETE methods\nfunc NewFooServiceConnector(baseEndpoint string, jwt *string) *FooServiceConnector {\n\treturn \u0026FooServiceConnector{\n\t\tjac.NewJac(baseEndpoint, jwt),\n\t\t\"foo/create\",\n\t}\n}\n\n// CreateFoo is an example of simple connector function\n// which uses jac.Jac to create new Foo instance via connector\nfunc (c *FooServiceConnector) CreateFoo(foo Foo) (*FooCreateResponse, error) {\n\t// rawing our Foo model\n\trawFoo, err := json.Marshal(foo)\n\tif err != nil {\n\t\t// your custom error handling\n\t}\n\n\t// creating response variable\n\tvar response FooCreateResponse\n\n\t// sending POST request to our service via connector\n\t// to create new Foo instance\n\tapiErrs, err := c.Post(c.createFooEndpoint, rawFoo, \u0026response)\n\tif err != nil {\n\t\t// your custom error handling\n\t}\n\tif len(apiErrs) != 0 {\n\t\t// you can handle API errs as you wish or just ignore them\n\t}\n\n\t// if err and apiErrs == nil, then you got a desired response from your service.\n\t// Now you can simply return it\n\treturn \u0026response, nil\n}\n```\n\nNote that you can configure `Jac` directly from config using `JACer`. It uses `Getter` which is responsible for retrieving info from config files and must implement next interface:\n```go\ntype Getter interface {\n    GetStringMap(key string) (map[string]interface{}, error)\n}\n```\n\n`JACer` has next methods to configure `Jac` connector or to simply retrieve `Jac` configuration:\n\n```go\n// JacConfig contains configurable data of a Jac\ntype JacConfig struct {\n\tURL string  `fig:\"url,required\"`\n\tJWT *string `fig:\"jwt\"`\n}\n\n// NewJACer returns an instance of JACer structure that configures Jac\nfunc NewJACer(getter kv.Getter) JACer {\n\treturn \u0026jacer{getter: getter}\n}\n\n// GetJacConfig returns Jac configuration info based on a provided config from kv.Getter\nfunc (c *jacer) GetJacConfig(configKey *string) JacConfig {\n\treturn c.once.Do(func() interface{} {\n\t\tif configKey == nil {\n\t\t\tconfigKey = \u0026jacDefaultConfigKey\n\t\t}\n\n\t\tvar (\n\t\t\tconfig = JacConfig{}\n\t\t\traw    = kv.MustGetStringMap(c.getter, *configKey)\n\t\t)\n\n\t\tif err := figure.Out(\u0026config).From(raw).Please(); err != nil {\n\t\t\tpanic(errors.Wrap(err, \"failed to figure out jac\"))\n\t\t}\n\n\t\treturn config\n\t}).(JacConfig)\n}\n\n// ConfigureJac returns configured Jac based on a provided config from kv.Getter\nfunc (c *jacer) ConfigureJac(configKey *string) Jac {\n\tcfg := c.GetJacConfig(configKey)\n\treturn NewJac(cfg.URL, cfg.JWT)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzspkg%2Fjac","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzspkg%2Fjac","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzspkg%2Fjac/lists"}