Skip to content

enigmaticmahesh/crud-api-with-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

CRUD with Golang


  • go mod init crud-with-go
    • This will create a go module with the name as go.mod in the proejct folder
  • go get "github.com/gorilla/mux"
    • We have used this gorilla/mux package to handle the routing in this application
    • We have installed the package using this command
    • We have 2 ways to install a package in command
      • go get <package_name>
      • go install <package_name>
    • But, the second one is deprecated and the first one is being used now. We can stil use the second one.
    • The only difference between them as far as I know is that get will check if the package is available, if not then it will download and then compile
    • Whereas install will directly compile, and will throw error if the package is not available
    • The get command will install the package in the GO_HOME
  • It has 5 routes/endpoints for the following:
    • /movies: will provide list of all the movies(Request: GET)
    • /movies: will create a movie(Request: POST). The request body should have the following structure
      {
        "isbn": "1193453248",
        "title": "Baahubali 2",
        "director": {
          "firstname": "S.S.",
          "lastname": "Rajamouli"
        }
      }
      
    • /movies/1: will provide movie with id = 1(Request: GET)
    • /movies/1: will delete movie with id = 1(Request: DELETE)
    • /movies/1: will update movie with id = 1(Request: PUT). The request body should be same as that of the Create Request

About

Simple Movie Crud Api

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages