Coder Social home page Coder Social logo

cst-t680-voter-api-assignment's Introduction

ToDo API Demo

This is a demo application showing many aspects of how to use the Golang Gin framework to create an API.

It keeps todo items in memory for this demo. The makefile allows you to exercise the API. For example you can load the database, query by item, and so on.

To see everything you can do you can just run make and get help. See below. Also notice that some of the make targets take parameters. To do this you add a key=value on the make command line. For example, to get a todo with an id of 2. you run make id=2 get-by-id

โžœ  todo-api git:(main) make
Usage make <TARGET>

  Targets:
           build                        Build the todo executable
           run                          Run the todo program from code
           run-bin                      Run the todo executable
           load-db                      Add sample data via curl
           get-by-id                    Get a todo by id pass id=<id> on command line
           get-all                      Get all todos
           update-2                     Update record 2, pass a new title in using title=<title> on command line
           delete-all                   Delete all todos
           delete-by-id                 Delete a todo by id pass id=<id> on command line
           get-v2                       Get all todos by done status pass done=<true|false> on command line
           get-v2-all                   Get all todos using version 2

Why use the gin framework?

Many people in the golang community are opposed to using frameworks because the standard library provides robust function out-of-the-box. However, the golang gin framework reduces a lot of the code you need to write and has a lot of nice features out of the box. As far as I know its still the most popular and widely used API framework for go.

Online documentation for gin can be found here:

  1. GitHub page: https://github.com/gin-gonic/gin
  2. Go Docs: https://pkg.go.dev/github.com/gin-gonic/gin?utm_source=godoc
  3. Gin homepage: https://gin-gonic.com/

cst-t680-voter-api-assignment's People

Contributors

donguyenhung avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.