{"id":15012984,"url":"https://github.com/fourcels/rest","last_synced_at":"2026-04-08T14:02:56.958Z","repository":{"id":154123765,"uuid":"631874551","full_name":"fourcels/rest","owner":"fourcels","description":"RESTful Web Services base on Echo","archived":false,"fork":false,"pushed_at":"2024-07-12T06:35:07.000Z","size":48,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-31T00:32:35.704Z","etag":null,"topics":["echo","go","jsonschema","openapi3","restful"],"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/fourcels.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":"2023-04-24T08:42:46.000Z","updated_at":"2024-07-12T06:33:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"bf79e2b3-7fe5-4a95-8e4e-216b128f552e","html_url":"https://github.com/fourcels/rest","commit_stats":{"total_commits":34,"total_committers":1,"mean_commits":34.0,"dds":0.0,"last_synced_commit":"eb9fd8e0f67b2fd66a333749223f08d895715d5c"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/fourcels/rest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fourcels%2Frest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fourcels%2Frest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fourcels%2Frest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fourcels%2Frest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fourcels","download_url":"https://codeload.github.com/fourcels/rest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fourcels%2Frest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31558389,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T10:21:54.569Z","status":"ssl_error","status_checked_at":"2026-04-08T10:21:38.171Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["echo","go","jsonschema","openapi3","restful"],"created_at":"2024-09-24T19:43:33.613Z","updated_at":"2026-04-08T14:02:56.939Z","avatar_url":"https://github.com/fourcels.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# REST with Clean Architecture for Go\n\n[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/github.com/fourcels/rest)\n\nInspired by [swaggest/rest](https://github.com/swaggest/rest)\n\n## Features\n\n- Built with [echo](https://github.com/labstack/echo).\n- Automatic OpenAPI 3 documentation with\n  [openapi-go](https://github.com/swaggest/openapi-go).\n- Automatic request JSON schema validation with\n  [jsonschema-go](https://github.com/swaggest/jsonschema-go),\n  [jsonschema](https://github.com/santhosh-tekuri/jsonschema).\n- Embedded [Swagger UI](https://swagger.io/tools/swagger-ui/).\n\n## Usage\n\n### Request\n\nGo struct with field tags defines input.\n\n```go\n// Declare input port type.\ntype helloInput struct {\n    Locale string `query:\"locale\" default:\"en-US\" pattern:\"^[a-z]{2}-[A-Z]{2}$\" enum:\"zh-CN,en-US\"`\n    Name   string `path:\"name\" minLength:\"3\"` // Field tags define parameter location and JSON schema constraints.\n\n    _      struct{} `title:\"My Struct\" description:\"Holds my data.\"`\n}\n```\n\nInput data can be located in:\n\n- `path` parameter in request URI, e.g. `/users/:name`,\n- `query` parameter in request URI, e.g. `/users?locale=en-US`,\n- `form` parameter in request body with `application/x-www-form-urlencoded`\n  content,\n- `formData` parameter in request body with `multipart/form-data` content,\n- `json` parameter in request body with `application/json` content,\n- `cookie` parameter in request cookie,\n- `header` parameter in request header.\n\nField tags\n\n- number `maximum`, `exclusiveMaximum`, `minimum`, `exclusiveMinimum`,\n  `multipleOf`\n- string `minLength`, `maxLength`, `pattern`, `format`\n- array `minItems`, `maxItems`, `uniqueItems`\n- all `title`, `description`, `default`, `const`, `enum`\n\nAdditional field tags describe JSON schema constraints, please check\n[documentation](https://github.com/swaggest/jsonschema-go#field-tags).\n\n## Response\n\n```go\n// Declare output port type.\ntype helloOutput struct {\n    Now     time.Time `header:\"X-Now\" json:\"-\"`\n    Message string    `json:\"message\"`\n    Sess    string    `cookie:\"sess,httponly,secure,max-age=86400,samesite=lax\"`\n}\n```\n\nOutput data can be located in:\n\n- `json` for response body with `application/json` content,\n- `header` for values in response header,\n- `cookie` for cookie values, cookie fields can have configuration in field tag\n  (same as in actual cookie, but with comma separation).\n\n## Example\n\n[Advance Example](/examples/advance/main.go)\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"time\"\n\n\t\"github.com/fourcels/rest\"\n\t\"github.com/labstack/echo/v4\"\n)\n\nfunc main() {\n\ts := rest.NewService()\n\ts.OpenAPI.Info.WithTitle(\"Basic Example\")\n\ts.GET(\"/hello/{name}\", hello())\n\n\t// Swagger UI endpoint at /docs.\n\ts.Docs(\"/docs\")\n\n\t// Start server.\n\tlog.Println(\"http://localhost:1323/docs\")\n\ts.Start(\":1323\")\n}\n\nfunc hello() rest.Interactor {\n\t// Declare input port type.\n\ttype input struct {\n\t\tName   string   `path:\"name\" minLength:\"3\"` // Field tags define parameter\n\t\tLocale string   `query:\"locale\" default:\"en-US\" pattern:\"^[a-z]{2}-[A-Z]{2}$\" enum:\"zh-CN,en-US\"`\n\t\t_      struct{} `title:\"My Struct\" description:\"Holds my data.\"`\n\t}\n\n\t// Declare output port type.\n\ttype output struct {\n\t\tNow     time.Time `header:\"X-Now\" json:\"-\"`\n\t\tMessage string    `json:\"message\"`\n\t}\n\n\tmessages := map[string]string{\n\t\t\"en-US\": \"Hello, %s!\",\n\t\t\"zh-CN\": \"你好, %s!\",\n\t}\n\treturn rest.NewHandler(func(c echo.Context, in input, out *output) error {\n\t\tmsg := messages[in.Locale]\n\t\tout.Now = time.Now()\n\t\tout.Message = fmt.Sprintf(msg, in.Name)\n\t\treturn nil\n\t})\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffourcels%2Frest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffourcels%2Frest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffourcels%2Frest/lists"}