This repository was archived by the owner on Apr 30, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,3 +21,25 @@ func (c Locations) List() revel.Result {
2121
2222 return c .RenderJSON (location )
2323}
24+
25+ type MyData struct {
26+ Device string
27+ Longitude string
28+ Latitude string
29+ }
30+
31+ func (c Locations ) Post () revel.Result {
32+ data := MyData {}
33+ c .Params .BindJSON (& data )
34+
35+ return c .RenderJSON (data )
36+
37+ location := []models.Location {}
38+
39+ result := DB .Find (& location )
40+ if result .Error != nil {
41+ return c .RenderError (errors .New ("Record Not Found" ))
42+ }
43+
44+ return c .RenderJSON (location )
45+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import "time"
55type Location struct {
66 ID uint `gorm:"primary_key"`
77 Updated time.Time
8+ Device string
9+ Color string
810 Longitude int
911 Latitude int
1012}
Original file line number Diff line number Diff line change @@ -29,6 +29,13 @@ func (_ tLocations) List(
2929 return revel .MainRouter .Reverse ("Locations.List" , args ).URL
3030}
3131
32+ func (_ tLocations ) Post (
33+ ) string {
34+ args := make (map [string ]string )
35+
36+ return revel .MainRouter .Reverse ("Locations.Post" , args ).URL
37+ }
38+
3239
3340type tLocationsArchive struct {}
3441var LocationsArchive tLocationsArchive
Original file line number Diff line number Diff line change @@ -49,6 +49,13 @@ func Register() {
4949 RenderArgNames : map [int ][]string {
5050 },
5151 },
52+ & revel.MethodType {
53+ Name : "Post" ,
54+ Args : []* revel.MethodArg {
55+ },
56+ RenderArgNames : map [int ][]string {
57+ },
58+ },
5259
5360 })
5461
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ module:testrunner
99
1010GET / App.Index
1111GET /v3/locations Locations.List
12+ POST /v3/locations Locations.Post
13+
1214GET /v3/locationsarchive LocationsArchive.List
1315
1416GET /v3/twitter Twitter.List
You can’t perform that action at this time.
0 commit comments