Skip to content

Latest commit

 

History

History
64 lines (57 loc) · 1.65 KB

README.md

File metadata and controls

64 lines (57 loc) · 1.65 KB

api

This is CRUD API for video service project

Usage

Download libraries which are required to run this program

  1. Download gin web framework.
go get github.com/gin-gonic/gin 
  1. Download postgresql open source object-relational database system and add to path.
  2. Include it in your project
go get github.com/lib/pq 
  1. Download yaml package that implements YAML support for the Go language.
go get gopkg.in/yaml.v2

Run setup.go file to initialize database

 go run cmd/setup.go

Run main.go file to use the CRUD API

go run cmd/setup.go

In this project, there are functions like:

  1. GET("/videos") // gets all videos that are saved
  2. POST("/videos") // creates a video
  3. GET("/videos/:id") // gets video by id
  4. PUT("/videos/:id") // updates video by id
  5. DELETE("/videos/:id") // deletes video by id

Directory structure

├───.idea  
├───cmd
|   ├───main.go
|   └───setup.go
├───configs
|   └───configs.yaml
├───entity
|   └───video.go
└───pkg
   ├───controller
   |   └───video-controller.go
   ├───db
   │   ├───SQL
   |   |    └───table.sql
   |   ├───db-connection.go
   |   └───db-functions.go
   ├───service
   |   └───video-service.go
   └───utils
       ├───convert
       |   └───strtoint.go
       └───reader
           └───readfile.go