<button class=btn>On this page <i>β‘οΈ</i></button></nav><header><h1>Building a Dockerized RESTful API application in Go</h1><p></p></header><div id=article-body><blockquote class=info><p><strong>π¨βπ«</strong> <strong>In this series…</strong></p><p>In this series, we are going to build a Dockerized Go RESTful API for a bookshelf with these steps:</p><ul><li>Create a basic server using Go’s <code>net/http</code> package and Dockerize it.</li><li>Add the database, SQL migration files, and create the <code>migrate</code> app to run these migration files.</li><li>Implement dynamic application configurations via environment variables.</li><li>Integrate Chi, add initial API routes, and generate OpenAPI specifications.</li><li>Integrate GORM, implement repository functions with tests, and invoke repository from the handlers.</li><li>Enhance error handling and integrate Validator v10 for form validations.</li><li>Implement error logs and request logs via Zerolog.</li></ul></blockquote><h2 id=-the-codebase>π¦ The codebase</h2><p>The completed API application supports the following API endpoints.</p><table><thead><tr><th>Name</th><th>HTTP Method</th><th>Route</th></tr></thead><tbody><tr><td>Health</td><td>GET</td><td>/livez</td></tr><tr><td>List Books</td><td>GET</td><td>/v1/books</td></tr><tr><td>Create Book</td><td>POST</td><td>/v1/books</td></tr><tr><td>Read Book</td><td>GET</td><td>/v1/books/{id}</td></tr><tr><td>Update Book</td><td>PUT</td><td>/v1/books/{id}</td></tr><tr><td>Delete Book</td><td>DELETE</td><td>/v1/books/{id}</td></tr></tbody></table><p>The sourcecode of the completed project can be found in <a href=http://github.com/learning-cloud-native-go/myapp target=_blank>learning-cloud-native-go/myapp</a> GitHub repository.</p><p>OK, Let’s get it started!</p></div><footer><time datetime=2024-01-21><i>π</i> Updated: 2024-01-21</time>
0 commit comments