{"id":20285435,"url":"https://github.com/mramshaw/restful-recipes","last_synced_at":"2025-12-30T21:34:52.814Z","repository":{"id":92906199,"uuid":"124961970","full_name":"mramshaw/RESTful-Recipes","owner":"mramshaw","description":"A more formal REST API in Golang.","archived":false,"fork":false,"pushed_at":"2020-11-10T03:26:11.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-04T03:44:35.399Z","etag":null,"topics":["docker","docker-compose","golang","json","postgres","postgresql","rest","restful","tdd"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mramshaw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-03-12T23:00:57.000Z","updated_at":"2021-08-26T10:10:16.000Z","dependencies_parsed_at":"2023-04-29T00:55:33.441Z","dependency_job_id":null,"html_url":"https://github.com/mramshaw/RESTful-Recipes","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mramshaw/RESTful-Recipes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FRESTful-Recipes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FRESTful-Recipes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FRESTful-Recipes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FRESTful-Recipes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mramshaw","download_url":"https://codeload.github.com/mramshaw/RESTful-Recipes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mramshaw%2FRESTful-Recipes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272852281,"owners_count":25004052,"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","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"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":["docker","docker-compose","golang","json","postgres","postgresql","rest","restful","tdd"],"created_at":"2024-11-14T14:26:42.493Z","updated_at":"2025-12-30T21:34:52.741Z","avatar_url":"https://github.com/mramshaw.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RESTful recipes\n\n[![Build status](https://travis-ci.org/mramshaw/RESTful-Recipes.svg?branch=master)](https://travis-ci.org/mramshaw/RESTful-Recipes)\n[![Coverage Status](http://codecov.io/github/mramshaw/RESTful-Recipes/coverage.svg?branch=master)](http://codecov.io/github/mramshaw/RESTful-Recipes?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mramshaw/RESTful-Recipes?style=flat-square)](https://goreportcard.com/report/github.com/mramshaw/RESTful-Recipes)\n[![GitHub release](https://img.shields.io/github/release/mramshaw/RESTful-Recipes.svg?style=flat-square)](https://github.com/mramshaw/RESTful-Recipes/releases)\n\nA more formal REST API in Golang.\n\nThis builds on my [Simple REST API in Golang](https://github.com/mramshaw/Simple-REST-API).\n\nAll data is stored in [PostgreSQL](https://www.postgresql.org/), all transfer is via JSON.\n\nAll dependencies are handled via [Docker](https://www.docker.com/products/docker) and [docker-compose](https://github.com/docker/compose).\n\nTDD (Test-Driven Development) is implemented; the build will fail if the tests do not pass.\n\nLikewise the build will fail if either __golint__ or __go vet__ fails.\n\nEnforces industry-standard __gofmt__ code formatting.\n\nAll testing can be done with [curl](CURLs.txt).\n\n\n## Features\n\n- uses [httprouter](https://github.com/julienschmidt/httprouter)\n- uses [Pure Go postgres driver](https://github.com/lib/pq)\n- uses [sqlx](#sqlx)\n- uses [testify assertions](#testify-assertions)\n\n#### sqlx\n\n[sqlx](https://github.com/jmoiron/sqlx) offers some [database/sql](https://godoc.org/database/sql)\nextensions.\n\nThere is a useful [Illustrated guide to SQLX](http://jmoiron.github.io/sqlx/).\n\nIt is not exactly a ___drop-in___ replacement for __database/sql__, as it is not quite a full\nsuperset. I found that I still needed to import both dependencies due to some primitives (such\nas __ErrNoRows__) that are not included in __sqlx__.\n\nI am not entirely sure I would use this library in my normal workflow, although it does offer\nsome interesting new options (the __Illustrated Guide__ is very helpful here).\n\n#### testify assertions\n\nIn terms of simplifying tests, [testify assertions](https://github.com/stretchr/testify/assert)\nreally make test cases much clearer - while also cutting down on boiler-plate.\n\nI'm generally pretty reluctant to introduce additional external dependencies unless they really\ndeliver value. In my opinion this addition is justified as the test cases become much easier\nto follow with assertions.\n\n\n## To Run\n\nThe command to run:\n\n    $ docker-compose up -d\n\nFor the first run, there will be a warning as `mramshaw4docs/golang-alpine:1.8` must be built.\n\nThis image will contain all of the Go dependencies and should only need to be built once.\n\nFor the very first run, `golang` may fail as it takes `postgres` some time to ramp up.\n\nA successful `golang` startup should show the following as the last line of \u003ckbd\u003edocker-compose logs golang\u003c/kbd\u003e\n\n    golang_1    | 2018/02/24 18:38:01 Now serving recipes ...\n\nIf this line does not appear, repeat the `docker-compose up -d` command (there is no penalty for this).\n\n\n## To Build:\n\nThe command to run:\n\n    $ docker-compose up -d\n\nOnce `make` indicates that `restful_recipes` has been built, can change `docker-compose.yml` as follows:\n\n1) Comment `command: make`\n\n2) Uncomment `command: ./restful_recipes`\n\n\n## For testing:\n\n[Optional] Start postgres:\n\n    $ docker-compose up -d postgres\n\nStart golang [if postgres is not running, this step will start it]:\n\n    $ docker-compose run --publish 80:8080 golang make\n\nSuccessful startup will be indicated as follows:\n\n    2018/02/24 16:27:10 Now serving recipes ...\n\nThis should make the web service available at:\n\n    http://localhost/v1/recipes\n\nOnce the service is running, it is possible to `curl` it. Check `CURLs.txt` for examples.\n\n\n## See what's running:\n\nThe command to run:\n\n    $ docker ps\n\n\n## View the build and/or execution logs\n\nThe command to run:\n\n    $ docker-compose logs golang\n\n\n## To Shutdown:\n\nThe command to run:\n\n    $ docker-compose down\n\n\n## Clean Up\n\nThe command to run:\n\n    $ docker-compose run golang make clean\n\n\n## To Do\n\n- [x] Upgrade to latest Go (as of posting, 1.15.4)\n- [x] Add Basic Auth to certain endpoints (POST, PUT/PATCH, DELETE)\n- [x] 12-Factor Basic Auth parameters\n- [x] Fix code coverage testing\n- [ ] Upgrade to latest Postgres\n- [ ] Persist back-end Postgres\n- [ ] Add a SWAGGER definition\n- [ ] Refactor data access into a DAO module\n- [ ] Add tests for the DAO\n- [ ] Add a health check\n- [x] Migrate from Gorilla/mux to julienschmidt/httprouter\n- [x] Migrate to [sqlx](https://github.com/jmoiron/sqlx) for some [sql](https://godoc.org/database/sql) extensions\n- [x] Implement [testify](https://github.com/stretchr/testify) [assertions](https://godoc.org/github.com/stretchr/testify/assert)\n- [ ] Implement [testify](https://github.com/stretchr/testify) [suite](https://godoc.org/github.com/stretchr/testify/suite)\n- [ ] Implement CORS\n- [ ] Implement graceful shutdown (available since __Go 1.8__)\n- [ ] Add Prometheus-style instrumentation\n\n\n## Credits\n\nInspired by this excellent tutorial by Kulshekhar Kabra:\n\n    https://semaphoreci.com/community/tutorials/building-and-testing-a-rest-api-in-go-with-gorilla-mux-and-postgresql\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmramshaw%2Frestful-recipes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmramshaw%2Frestful-recipes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmramshaw%2Frestful-recipes/lists"}