|
| 1 | +/** |
| 2 | +* Copyright © 2017, ACM@UIUC |
| 3 | +* |
| 4 | +* This file is part of the Groot Project. |
| 5 | +* |
| 6 | +* The Groot Project is open source software, released under the University of |
| 7 | +* Illinois/NCSA Open Source License. You should have received a copy of |
| 8 | +* this license in a file with the distribution. |
| 9 | +**/ |
| 10 | + |
| 11 | +package services |
| 12 | + |
| 13 | +import ( |
| 14 | + "net/http" |
| 15 | + |
| 16 | + "github.com/acm-uiuc/arbor" |
| 17 | + "github.com/acm-uiuc/groot-api-gateway/config" |
| 18 | +) |
| 19 | + |
| 20 | +//Location |
| 21 | +const RequestURL string = config.RequestURL |
| 22 | + |
| 23 | +//Service Data Type |
| 24 | +const RequestFormat string = "JSON" |
| 25 | + |
| 26 | +//API Interface |
| 27 | +var RequestRoutes = arbor.RouteCollection{ |
| 28 | + arbor.Route{ |
| 29 | + "PostRequest", |
| 30 | + "POST", |
| 31 | + "/request", |
| 32 | + PostRequest, |
| 33 | + }, |
| 34 | + arbor.Route{ |
| 35 | + "GetRequest", |
| 36 | + "GET", |
| 37 | + "/request", |
| 38 | + GetRequest, |
| 39 | + }, |
| 40 | + arbor.Route{ |
| 41 | + "GetRequestByID", |
| 42 | + "GET", |
| 43 | + "/request/{id}", |
| 44 | + GetRequestByID, |
| 45 | + }, |
| 46 | + arbor.Route{ |
| 47 | + "UpdateRequest", |
| 48 | + "PUT", |
| 49 | + "/request/{id}", |
| 50 | + UpdateRequest, |
| 51 | + }, |
| 52 | +} |
| 53 | + |
| 54 | +// arbor.Route handler |
| 55 | +func PostRequest(w http.ResponseWriter, r *http.Request) { |
| 56 | + arbor.POST(w, RequestURL+r.URL.String(), RequestFormat, "", r) |
| 57 | +} |
| 58 | + |
| 59 | +func GetRequest(w http.ResponseWriter, r *http.Request) { |
| 60 | + arbor.GET(w, RequestURL+r.URL.String(), RequestFormat, "", r) |
| 61 | +} |
| 62 | + |
| 63 | +func GetRequestByID(w http.ResponseWriter, r *http.Request) { |
| 64 | + arbor.GET(w, RequestURL+r.URL.String(), RequestFormat, "", r) |
| 65 | +} |
| 66 | + |
| 67 | +func UpdateRequest(w http.ResponseWriter, r *http.Request) { |
| 68 | + arbor.PUT(w, RequestURL+r.URL.String(), RequestFormat, "", r) |
| 69 | +} |
0 commit comments