-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (30 loc) · 1.1 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import "github.com/gin-gonic/gin"
const dns = "host=db user=postgres password=abc123. dbname=dogstore port=5432 sslmode=disable TimeZone=Europe/Madrid"
func main() {
r := gin.Default()
configureDB(dns)
getInstance().AutoMigrate(new(breed), new(owner), new(dog))
dogsGroup := r.Group("dogstore")
{
dogsGroup.GET(breedsPath, hGetBreed)
dogsGroup.POST(breedsPath, hAddBreed)
dogsGroup.GET(breedByNamePath, hGetBreed)
dogsGroup.DELETE(breedByNamePath, hDelBreed)
dogsGroup.GET(ownersPath, hGetOwner)
dogsGroup.POST(ownersPath, hAddOwner)
dogsGroup.GET(ownerByIdPath, hGetOwner)
dogsGroup.DELETE(ownerByIdPath, hDelOwner)
dogsGroup.GET(dogsByBreedPath, hGetDog)
dogsGroup.POST(dogsByBreedPath, hAddDog)
dogsGroup.GET(dogByBreedByNamePath, hGetDog)
dogsGroup.DELETE(dogByBreedByNamePath, hDelDog)
dogsGroup.GET(dogsByOwnerPath, hGetDog)
dogsGroup.POST(dogsByOwnerPath, hAddDog)
dogsGroup.GET(dogByOwnerByNamePath, hGetDog)
dogsGroup.DELETE(dogByOwnerByNamePath, hDelDog)
dogsGroup.GET(dogsPath, hGetDog)
dogsGroup.GET(dogByNamePath, hGetDog)
}
r.Run(":8080")
}