{"id":16607132,"url":"https://github.com/ryankurte/go-api","last_synced_at":"2025-10-15T09:26:24.454Z","repository":{"id":57524218,"uuid":"120837196","full_name":"ryankurte/go-api","owner":"ryankurte","description":"An API helper framework build on top of gocraft/web","archived":false,"fork":false,"pushed_at":"2018-03-02T02:37:49.000Z","size":39,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-09T13:18:50.048Z","etag":null,"topics":["api","framework","golang","helper"],"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/ryankurte.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}},"created_at":"2018-02-09T00:51:49.000Z","updated_at":"2021-03-28T18:39:16.000Z","dependencies_parsed_at":"2022-09-26T18:10:53.278Z","dependency_job_id":null,"html_url":"https://github.com/ryankurte/go-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryankurte%2Fgo-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryankurte%2Fgo-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryankurte%2Fgo-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryankurte%2Fgo-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryankurte","download_url":"https://codeload.github.com/ryankurte/go-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242768086,"owners_count":20182099,"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":["api","framework","golang","helper"],"created_at":"2024-10-12T01:11:44.383Z","updated_at":"2025-10-15T09:26:19.437Z","avatar_url":"https://github.com/ryankurte.png","language":"Go","readme":"# go-api\n\nA typed API builder project to remove a bunch of boilerplate and repetition from golang API projects.\nThis wires together a bunch of common dependencies, uses some reflection based magic to provide typed API functions and common error handling, and is intended to encode some best practices in API security.\n\n## Status\n\n[![Build Status](https://travis-ci.org/ryankurte/go-api.svg?branch=master)](https://travis-ci.org/ryankurte/go-api)\n[![Documentation](https://img.shields.io/badge/docs-godoc-blue.svg)](https://godoc.org/github.com/ryankurte/go-api)\n[![Release](https://img.shields.io/github/release/ryankurte/go-api.svg)](https://github.com/ryankurte/go-api)\n\n\n## Overview\n\n- [core](lib/) collects components and exposes the user API\n- [formats](lib/formats) provide format encoding/decoding functions\n- [options](lib/options) provide base api server options and option parsing\n- [plugins](lib/plugins) provide plugins for meta analysis of the API implementation\n- [security](lib/security) provide security extensions for the API implementation\n- [servers](lib/servers) provide base server handling (ie. http server, AWS lambda)\n- [wrappers](lib/wrappers) provide wrapping functions for typed api endpoints\n\n## Usage\n\nInstall with `go get github.com/ryankurte/go-api`.\n\nCreate an application options object that inherits from `options.Base` and load with `options.Parse(\u0026o)`.\nOptions are parsed using [jessevdk/go-flags](https://github.com/jessevdk/go-flags).\n\n``` go\nimport (\n    \"github.com/ryankurte/go-api/lib/options\"\n)\n\ntype AppConfig struct {\n    options.Base\n    ...\n}\n\n...\n\no := AppConfig{}\nerr := options.Parse(\u0026o)\nif err != nil {\n    os.Exit(0)\n} \n```\n\nCreate a base application context with type handlers and a base `api.API` router, the attach handlers to the API router.\n\nHandler functions support input parameters:\n- `(ctx ContextType)`\n- `(ctx ContextType, i InputType)`\n- `(ctx ContextType, i InputType, http.header)`\n\nAnd output parameters:\n- `(OutputType, error)`\n- `(OutputType, int, error)`\n- `(OutputType, int, http.Header, error)`\n\nWhere `ContextType`, `InputType` and `OutputType` are user defined structs and int is a `http.Status` code. \nInput and output types are validated after decoding and prior to encoding using [asaskevich/govalidator](https://github.com/asaskevich/govalidator).\nThe underlying mux is provided by [gocraft/web](https://github.com/gocraft/web).\n\n``` go\nimport (\n    \"github.com/ryankurte/go-api/lib/options\"\n)\n\ntype AppContext struct {\n\t...\n}\n\nfunc (c *AppContext) FakeEndpoint(a AppContext, i Request) (Response, error) {\n\t...\n}\n\nctx := AppContext{\"Whoop whoop\"}\napi, err := api.New(ctx, \u0026o.Base)\nif err != nil {\n    log.Print(err)\n    os.Exit(-1)\n}\n\nerr = api.RegisterEndpoint(\"/\", \"POST\", (*AppContext).FakeEndpoint)\n\n```\n\nYou can then launch a server with `api.Run()` and exit wth `api.Close()`.\n\nCheck out [example.go](example.go) for a working example.\n\n------\n\nIf you have any questions, comments, or suggestions, feel free to open an issue or a pull request.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryankurte%2Fgo-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryankurte%2Fgo-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryankurte%2Fgo-api/lists"}