├── .gitignore ├── .travis.yml ├── Dockerfile ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── README.md ├── build.sh ├── config └── config.go.template ├── server.go └── services ├── activedirectory.go ├── auth.go ├── credits.go ├── events.go ├── gigs.go ├── groups.go ├── hardware.go ├── memes.go ├── merch.go ├── notification.go ├── quotes.go ├── recruiters.go ├── request.go ├── services.go └── users.go /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | 26 | *.DS_Store 27 | 28 | build 29 | 30 | config/config.go 31 | 32 | vendor/ 33 | log/ 34 | clients.db 35 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | language: go 3 | go: 4 | - 1.8 5 | - 1.8.x 6 | matrix: 7 | allow_failures: 8 | - go: 1.8.x 9 | services: 10 | - docker 11 | install: 12 | - go get -u github.com/golang/dep/... 13 | - dep ensure 14 | - cp config/config.go.template config/config.go 15 | - docker build -t groot-api-gateway . 16 | script: 17 | - "./build.sh" 18 | notifications: 19 | email: false 20 | slack: 21 | secure: uLYKU24h8GQfineHkwSFEPhkv9OMDDB2eOfWbjYQ3M5YurlcyzIeVqsLhfvtwKJqI+YwLkifTRhsfnnSQF4r0FkMVM5ehe7so8+hyQPC0xnxP1LMpRvgzMz8P5kT/itNe6IujkxI++vslOY/pLlkWIg9XYDQN3/c2LqCIvHPn5IqH4HHLIRIC7yHx6mW0OQBczlkxAzj48kqFZTBaWJN1FiD1x6dCBlzp8miZ/PNkBFsKU/yAqkgN7/JL2bqxHZpDnLJoEJsxamlx/3vR7r2PG1j28RudZfM6o0yoOqQcFSq23RldSIDINFudbsQh7F/O5aoY/KuhotCa8Kx1Wxge7eDEk0ttdiL6EOlK9Xjcmwr2V3PUwJkgYJEHmanqBfO4DZtc56IbWE6CLZQW0kubzA8619+/YkKt5m8f4FtN7gbKwKqWueyDudfTwx5wxbCRcCnV1OEF8Z/tfd7GOwWb9II1kif27zSf5snUu1XQHuWYxipr51zeHtGcVqGzmz5tiKzdIDfI35uHWmAnpHJ63T3zo/bKJFpWcUYcPM3b1FyAX20DRDOfFGOY1wYZ4z35fNV3Nfuimj3VVBKwckKgmuylTEvBL1z2nGB6nxijXDlXUijyO4MLi/H7HnhvftqrATDDf/QmgPNpm4UUN/zjYSDRQyNbTXnah8D51kgjtc= 22 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM golang:1.8-alpine 3 | MAINTAINER ACM@UIUC 4 | 5 | # Get git 6 | RUN apk add --update git bash 7 | 8 | # Get dep 9 | RUN go get -u github.com/golang/dep/... 10 | 11 | # Create folder for client key database 12 | RUN mkdir -p /var/groot-api-gateway/ 13 | 14 | # Bundle app source 15 | ADD . $GOPATH/src/github.com/acm-uiuc/groot-api-gateway 16 | WORKDIR $GOPATH/src/github.com/acm-uiuc/groot-api-gateway 17 | 18 | # Download and install external dependencies 19 | RUN dep ensure -vendor-only 20 | 21 | # Build groot 22 | RUN ./build.sh 23 | 24 | CMD ["./build/groot-api-gateway"] 25 | -------------------------------------------------------------------------------- /Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | name = "github.com/acm-uiuc/arbor" 6 | packages = [".","logger","proxy","security","server","services"] 7 | revision = "f727ba3a5160e495a81cb81497ac1292b7e34552" 8 | version = "v0.2.4" 9 | 10 | [[projects]] 11 | branch = "master" 12 | name = "github.com/golang/snappy" 13 | packages = ["."] 14 | revision = "553a641470496b2327abcac10b36396bd98e45c9" 15 | 16 | [[projects]] 17 | name = "github.com/gorilla/context" 18 | packages = ["."] 19 | revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a" 20 | version = "v1.1" 21 | 22 | [[projects]] 23 | branch = "master" 24 | name = "github.com/gorilla/mux" 25 | packages = ["."] 26 | revision = "599cba5e7b6137d46ddf58fb1765f5d928e69604" 27 | 28 | [[projects]] 29 | name = "github.com/kennygrant/sanitize" 30 | packages = ["."] 31 | revision = "2e6820834a1f36c626bf19a253b7d3cc060e9b8b" 32 | version = "v1.2.3" 33 | 34 | [[projects]] 35 | branch = "master" 36 | name = "github.com/syndtr/goleveldb" 37 | packages = ["leveldb","leveldb/cache","leveldb/comparer","leveldb/errors","leveldb/filter","leveldb/iterator","leveldb/journal","leveldb/memdb","leveldb/opt","leveldb/storage","leveldb/table","leveldb/util"] 38 | revision = "adf24ef3f94bd13ec4163060b21a5678f22b429b" 39 | 40 | [[projects]] 41 | branch = "master" 42 | name = "golang.org/x/net" 43 | packages = ["html","html/atom"] 44 | revision = "da118f7b8e5954f39d0d2130ab35d4bf0e3cb344" 45 | 46 | [solve-meta] 47 | analyzer-name = "dep" 48 | analyzer-version = 1 49 | inputs-digest = "7abf4ba1a608b4324f95e1f7402774fe9547baf991a91afee500534ec22c8511" 50 | solver-name = "gps-cdcl" 51 | solver-version = 1 52 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | [[constraint]] 3 | name = "github.com/arbor-dev/arbor" 4 | version = ">=0.2.5, <1.0.0" 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | University of Illinois/NCSA Open Source License 2 | 3 | Copyright (c) 2017 ACM@UIUC. All rights reserved. 4 | 5 | Developed by: Groot Development Team 6 | ACM@UIUC 7 | https://acm.illinois.edu 8 | 9 | Permission is hereby granted, free of charge, to any person 10 | obtaining a copy of this software and associated documentation files 11 | (the "Software"), to deal with the Software without restriction, 12 | including without limitation the rights to use, copy, modify, merge, 13 | publish, distribute, sublicense, and/or sell copies of the Software, 14 | and to permit persons to whom the Software is furnished to do so, 15 | subject to the following conditions: 16 | 17 | * Redistributions of source code must retain the above copyright notice, 18 | this list of conditions and the following disclaimers. 19 | 20 | * Redistributions in binary form must reproduce the above copyright 21 | notice, this list of conditions and the following disclaimers in the 22 | documentation and/or other materials provided with the distribution. 23 | 24 | * Neither the names of ACM@UIUC, the Groot Development Team nor the names of its 25 | contributors may be used to endorse or promote products derived from 26 | this Software without specific prior written permission. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 29 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH 34 | THE SOFTWARE. 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GROOT 2 | 3 | [![Build Status](https://travis-ci.org/acm-uiuc/groot-api-gateway.svg?branch=master)](https://travis-ci.org/acm-uiuc/groot-api-gateway) 4 | 5 | This repo contains the API Gateway written in Fall of 2015 6 | It provides the following capabilities: 7 | * Easy registration of services 8 | * Universal Authentication for the entire application - via an external authentication provided (Atlassian crowd) 9 | * Proxying API calls 10 | * Managing inter-service communication 11 | 12 | When registering as service specify the data encoding and when requesting a resource though groot make the request using json. 13 | 14 | [![Join the chat at https://acm-uiuc.slack.com/messages/C6XGZD212/](https://img.shields.io/badge/slack-groot-724D71.svg)](https://acm-uiuc.slack.com/messages/C6XGZD212/) 15 | 16 | 17 | 18 | 19 | ## RUNNING GROOT 20 | 21 | Add the API spec in a new file (ex. todo.go) in the services package 22 | 23 | There is a set of proxy api calls defined by the Arbor framework which the API Gateway is written in. 24 | 25 | AS OF 4/24/17 26 | ```go 27 | /** 28 | * Pass the http Request from the client and the ResponseWriter it expects 29 | * Pass the target url of the backend service (not the url the client called) 30 | * Pass the format of the service 31 | * Pass a authorization token (optional) 32 | * Will call the service and return the result to the client. 33 | **/ 34 | arbor.GET(w http.ResponseWriter, url string, format string, token string, r *http.Request) 35 | ``` 36 | ```go 37 | /** 38 | * Pass the http Request from the client and the ResponseWriter it expects 39 | * Pass the target url of the backend service (not the url the client called) 40 | * Passes the encoded json(only format currently supported) to the service. 41 | * Pass a authorization token (optional) 42 | * Will call the service and return the result to the client. 43 | **/ 44 | arbor.POST(w http.ResponseWriter, url string, format string, token string, r *http.Request) 45 | ``` 46 | ```go 47 | /** 48 | * Pass the http Request from the client and the ResponseWriter it expects 49 | * Pass the target url of the backend service (not the url the client called) 50 | * Passes the encoded json(only format currently supported) to the service. 51 | * Pass a authorization token (optional) 52 | * Will call the service and return the result to the client. 53 | **/ 54 | arbor.PUT(w http.ResponseWriter, url string, format string, token string, r *http.Request) 55 | ``` 56 | ```go 57 | /** 58 | * Pass the http Request from the client and the ResponseWriter it expects 59 | * Pass the target url of the backend service (not the url the client called) 60 | * Pass a authorization token (optional) 61 | * Will call the service and return the result to the client. 62 | **/ 63 | arbor.DELETE(w http.ResponseWriter, url string, format string, token string, r *http.Request) 64 | ``` 65 | 66 | All secret data should be kept in a file called config.go in the config directory 67 | 68 | Make sure you have go dependencey management installed 69 | 70 | ``` 71 | go get github.com/golang/dep/... 72 | ``` 73 | 74 | Install Dependencies [First time setup] 75 | 76 | ```sh 77 | dep ensure 78 | ``` 79 | 80 | Compile the service 81 | 82 | ```sh 83 | ./build.sh 84 | ``` 85 | 86 | ## CLI 87 | ```sh 88 | groot-api-gateway [-r | --register-client client_name] [-c | --check-registration token] [-u | --unsecured] 89 | ``` 90 | 91 | -r | --register-client *client_name* 92 | > registers a client, generates a token 93 | 94 | -c | --check-registration *token* 95 | > checks if a token is valid and returns name of client 96 | 97 | -u | --unsecured 98 | > runs groot without the security layer 99 | 100 | *without args* 101 | > runs groot with the security layer 102 | 103 | 104 | ## Docker 105 | 106 | #### Creating a client key: 107 | ``` 108 | docker-compose run groot-api-gateway ./build/groot-api-gateway -r 109 | ``` 110 | 111 | #### Checking a client key: 112 | ``` 113 | docker-compose run groot-api-gateway ./build/groot-api-gateway -c 114 | ``` 115 | 116 | #### Config Values 117 | To allow all services to work with the docker network, make sure to set these values in `config.go`: 118 | ```go 119 | //Service hosts 120 | const CreditsURL = "http://groot-credits-service:8765" 121 | const EventsURL = "http://groot-events-service:8002" 122 | const GigsURL = "http://groot-gigs-service:8964" 123 | const GroupsURL = "http://groot-groups-service:9001" 124 | const HardwareURL = "http://groot:4523/api/v1.0" 125 | const MemesURL = "http://groot-meme-service:42069" 126 | const MerchURL = "http://groot-merch-service:6969" 127 | const QuotesURL = "http://groot-quotes-service:9494" 128 | const RecruiterURL = "http://groot-recruiters-service:4567" 129 | const UsersURL = "http://groot-users-service:8001" 130 | 131 | //Arbor configurations 132 | func LoadArborConfig() { 133 | security.AccessLogLocation = "/var/groot-api-gateway/access.log" 134 | security.ClientRegistryLocation = "/var/groot-api-gateway/clients.db" 135 | proxy.AccessControlPolicy = "*" 136 | } 137 | ``` 138 | 139 | ## License 140 | 141 | This project is licensed under the University of Illinois/NCSA Open Source License. For a full copy of this license take a look at the LICENSE file. 142 | 143 | When contributing new files to this project, preappend the following header to the file as a comment: 144 | 145 | ``` 146 | Copyright © 2017, ACM@UIUC 147 | 148 | This file is part of the Groot Project. 149 | 150 | The Groot Project is open source software, released under the University of Illinois/NCSA Open Source License. 151 | You should have received a copy of this license in a file with the distribution. 152 | ``` 153 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p log/prod 4 | 5 | ######################################################################### 6 | # # 7 | # # 8 | # I N S T A L L G R O O T A P I G A T E W A Y # 9 | # # 10 | # # 11 | ######################################################################### 12 | go get -u github.com/arbor-dev/arbor/... 13 | 14 | echo Building config 15 | go install github.com/acm-uiuc/groot-api-gateway/config 16 | 17 | echo Building services 18 | go install github.com/acm-uiuc/groot-api-gateway/services 19 | 20 | echo Building groot-api-gateway 21 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 22 | mkdir -p build 23 | echo Placing binary in [PATH TO GROOT]/build 24 | (cd $DIR; go build -o $DIR/build/groot-api-gateway .) 25 | -------------------------------------------------------------------------------- /config/config.go.template: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "github.com/arbor-dev/arbor/proxy" 5 | "github.com/arbor-dev/arbor/security" 6 | ) 7 | 8 | //Groot Specific configurations 9 | const AuthPrefix = "Basic " 10 | const AuthURL string = "http://localhost:8008" 11 | const AuthToken string = "" 12 | 13 | //Service hosts 14 | const ADURL = "http://localhost:8998" 15 | const CreditsURL = "http://localhost:8765" 16 | const EventsURL = "http://localhost:8002" 17 | const GigsURL = "http://localhost:8964" 18 | const GroupsURL = "http://localhost:9001" 19 | const HardwareURL = "http://localhost:4523/api/v1.0" 20 | const MemesURL = "http://localhost:42069" 21 | const MerchURL = "http://localhost:6969" 22 | const NotificationURL = "http://localhost:1122" 23 | const QuotesURL = "http://localhost:9494" 24 | const RecruiterURL = "http://localhost:4567" 25 | const RequestURL = "http://localhost:5656" 26 | const UsersURL = "http://localhost:8001" 27 | 28 | //Arbor configurations 29 | func LoadArborConfig() { 30 | security.AccessLogLocation = "log/access.log" 31 | security.ClientRegistryLocation = "clients.db" 32 | proxy.AccessControlPolicy = "*" 33 | } 34 | -------------------------------------------------------------------------------- /server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/acm-uiuc/groot-api-gateway/config" 5 | "github.com/acm-uiuc/groot-api-gateway/services" 6 | "github.com/arbor-dev/arbor" 7 | ) 8 | 9 | func main() { 10 | config.LoadArborConfig() 11 | Routes := services.RegisterAPIs() 12 | arbor.Boot(Routes, "0.0.0.0", 8000) 13 | } 14 | -------------------------------------------------------------------------------- /services/activedirectory.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const ADURL string = config.ADURL 22 | 23 | //Service Data Type 24 | const ADFormat string = "JSON" 25 | 26 | //API Interface 27 | var ADRoutes = arbor.RouteCollection{ 28 | arbor.Route{ 29 | "AddUser", 30 | "POST", 31 | "/activedirectory/add", 32 | AddUser, 33 | }, 34 | } 35 | 36 | // arbor.Route handler 37 | func AddUser(w http.ResponseWriter, r *http.Request) { 38 | arbor.POST(w, ADURL+r.URL.String(), ADFormat, "", r) 39 | } 40 | -------------------------------------------------------------------------------- /services/auth.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const AuthURL string = config.AuthURL 22 | 23 | //token 24 | const AuthToken string = config.AuthPrefix + config.AuthToken 25 | 26 | //Service Data Type 27 | const AuthFormat string = "JSON" 28 | 29 | //API Interface 30 | var AuthRoutes = arbor.RouteCollection{ 31 | arbor.Route{ 32 | "NewSession", 33 | "POST", 34 | "/session", 35 | NewSession, 36 | }, 37 | arbor.Route{ 38 | "EndUsersSessions", 39 | "DELETE", 40 | "/session?username={username}", 41 | EndUsersSessions, 42 | }, 43 | arbor.Route{ 44 | "GetAuthenticatedUser", 45 | "GET", 46 | "/session/{token}", 47 | GetAuthenticatedUser, 48 | }, 49 | arbor.Route{ 50 | "ValidateSession", 51 | "POST", 52 | "/session/{token}", 53 | ValidateSession, 54 | }, 55 | arbor.Route{ 56 | "EndSession", 57 | "DELETE", 58 | "/session/{token}", 59 | EndSession, 60 | }, 61 | } 62 | 63 | // arbor.Route handler 64 | // w = writer, r = reader 65 | func NewSession(w http.ResponseWriter, r *http.Request) { 66 | arbor.POST(w, AuthURL+r.URL.String(), AuthFormat, AuthToken, r) 67 | } 68 | 69 | func EndUsersSessions(w http.ResponseWriter, r *http.Request) { 70 | arbor.DELETE(w, AuthURL+r.URL.String(), AuthFormat, AuthToken, r) 71 | } 72 | 73 | func GetAuthenticatedUser(w http.ResponseWriter, r *http.Request) { 74 | arbor.GET(w, AuthURL+r.URL.String(), AuthFormat, AuthToken, r) 75 | } 76 | 77 | func ValidateSession(w http.ResponseWriter, r *http.Request) { 78 | arbor.POST(w, AuthURL+r.URL.String(), AuthFormat, AuthToken, r) 79 | } 80 | 81 | func EndSession(w http.ResponseWriter, r *http.Request) { 82 | arbor.DELETE(w, AuthURL+r.URL.String(), AuthFormat, AuthToken, r) 83 | } 84 | -------------------------------------------------------------------------------- /services/credits.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const CreditsURL string = config.CreditsURL 22 | 23 | //Service Data Type 24 | const CreditsFormat string = "JSON" 25 | 26 | //API Interface 27 | var CreditsRoutes = arbor.RouteCollection{ 28 | arbor.Route{ 29 | "NewPayment", 30 | "POST", 31 | "/payment", 32 | NewPayment, 33 | }, 34 | arbor.Route{ 35 | "GetCreditsUser", 36 | "GET", 37 | "/credits/users/{netid}", 38 | GetCreditsUser, 39 | }, 40 | arbor.Route{ 41 | "GetCreditsUserMultiple", 42 | "GET", 43 | "/credits/users", 44 | GetCreditsUserMultiple, 45 | }, 46 | arbor.Route{ 47 | "GetTransactions", 48 | "GET", 49 | "/credits/transactions", 50 | GetTransactions, 51 | }, 52 | arbor.Route{ 53 | "CreateTransaction", 54 | "POST", 55 | "/credits/transactions", 56 | CreateTransaction, 57 | }, 58 | arbor.Route{ 59 | "DeleteTransaction", 60 | "DELETE", 61 | "/credits/transactions/{id}", 62 | DeleteTransaction, 63 | }, 64 | } 65 | 66 | // arbor.Route handler 67 | func NewPayment(w http.ResponseWriter, r *http.Request) { 68 | arbor.POST(w, CreditsURL+r.URL.String(), CreditsFormat, "", r) 69 | } 70 | 71 | func GetCreditsUser(w http.ResponseWriter, r *http.Request) { 72 | arbor.GET(w, CreditsURL+r.URL.String(), CreditsFormat, "", r) 73 | } 74 | 75 | func GetCreditsUserMultiple(w http.ResponseWriter, r *http.Request) { 76 | arbor.GET(w, CreditsURL+r.URL.String(), CreditsFormat, "", r) 77 | } 78 | 79 | func GetTransactions(w http.ResponseWriter, r *http.Request) { 80 | arbor.GET(w, CreditsURL+r.URL.String(), CreditsFormat, "", r) 81 | } 82 | 83 | func CreateTransaction(w http.ResponseWriter, r *http.Request) { 84 | arbor.POST(w, CreditsURL+r.URL.String(), CreditsFormat, "", r) 85 | } 86 | 87 | func DeleteTransaction(w http.ResponseWriter, r *http.Request) { 88 | arbor.DELETE(w, CreditsURL+r.URL.String(), CreditsFormat, "", r) 89 | } 90 | -------------------------------------------------------------------------------- /services/events.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const EventsURL string = config.EventsURL 22 | 23 | //Service Data Type 24 | const EventsFormat string = "JSON" 25 | 26 | //API Interface 27 | var EventsRoutes = arbor.RouteCollection{ 28 | arbor.Route{ 29 | "GetEvents", 30 | "GET", 31 | "/events", 32 | GetEvents, 33 | }, 34 | arbor.Route{ 35 | "GetUpcomingEvents", 36 | "GET", 37 | "/events/upcoming", 38 | GetUpcomingEvents, 39 | }, 40 | } 41 | 42 | // arbor.Route handler 43 | func GetEvents(w http.ResponseWriter, r *http.Request) { 44 | arbor.GET(w, EventsURL+r.URL.String(), EventsFormat, "", r) 45 | } 46 | 47 | func GetUpcomingEvents(w http.ResponseWriter, r *http.Request) { 48 | arbor.GET(w, EventsURL+r.URL.String(), EventsFormat, "", r) 49 | } 50 | -------------------------------------------------------------------------------- /services/gigs.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const GigsURL string = config.GigsURL 22 | 23 | //Service Data Type 24 | const GigFormat string = "JSON" 25 | 26 | //API Interface 27 | var GigsRoutes = arbor.RouteCollection{ 28 | arbor.Route{ 29 | "ListGigs", 30 | "GET", 31 | "/gigs", 32 | ListGigs, 33 | }, 34 | arbor.Route{ 35 | "NewGig", 36 | "POST", 37 | "/gigs", 38 | NewGig, 39 | }, 40 | arbor.Route{ 41 | "GigInfo", 42 | "GET", 43 | "/gigs/{gig_id}", 44 | GigInfo, 45 | }, 46 | arbor.Route{ 47 | "EditGig", 48 | "PUT", 49 | "/gigs/{gig_id}", 50 | EditGig, 51 | }, 52 | arbor.Route{ 53 | "DeleteGig", 54 | "DELETE", 55 | "/gigs/{gig_id}", 56 | DeleteGig, 57 | }, 58 | arbor.Route{ 59 | "ListClaims", 60 | "GET", 61 | "/gigs/claims", 62 | ListClaims, 63 | }, 64 | arbor.Route{ 65 | "CreateClaim", 66 | "POST", 67 | "/gigs/claims", 68 | CreateClaim, 69 | }, 70 | arbor.Route{ 71 | "ListSingleClaim", 72 | "GET", 73 | "/gigs/claims/{claim_id}", 74 | ListSingleClaim, 75 | }, 76 | arbor.Route{ 77 | "AcceptClaim", 78 | "PUT", 79 | "/gigs/claims/{claim_id}", 80 | AcceptClaim, 81 | }, 82 | arbor.Route{ 83 | "DeleteClaim", 84 | "DELETE", 85 | "/gigs/claims/{claim_id}", 86 | DeleteClaim, 87 | }, 88 | } 89 | 90 | //Route handler 91 | func ListGigs(w http.ResponseWriter, r *http.Request) { 92 | arbor.GET(w, GigsURL+r.URL.String(), GigFormat, "", r) 93 | } 94 | 95 | func NewGig(w http.ResponseWriter, r *http.Request) { 96 | arbor.POST(w, GigsURL+r.URL.String(), GigFormat, "", r) 97 | } 98 | 99 | func GigInfo(w http.ResponseWriter, r *http.Request) { 100 | arbor.GET(w, GigsURL+r.URL.String(), GigFormat, "", r) 101 | } 102 | 103 | func CreateClaim(w http.ResponseWriter, r *http.Request) { 104 | arbor.POST(w, GigsURL+r.URL.String(), GigFormat, "", r) 105 | } 106 | 107 | func EditGig(w http.ResponseWriter, r *http.Request) { 108 | arbor.PUT(w, GigsURL+r.URL.String(), GigFormat, "", r) 109 | } 110 | 111 | func DeleteGig(w http.ResponseWriter, r *http.Request) { 112 | arbor.DELETE(w, GigsURL+r.URL.String(), GigFormat, "", r) 113 | } 114 | 115 | func ListClaims(w http.ResponseWriter, r *http.Request) { 116 | arbor.GET(w, GigsURL+r.URL.String(), GigFormat, "", r) 117 | } 118 | 119 | func ListSingleClaim(w http.ResponseWriter, r *http.Request) { 120 | arbor.GET(w, GigsURL+r.URL.String(), GigFormat, "", r) 121 | } 122 | 123 | func AcceptClaim(w http.ResponseWriter, r *http.Request) { 124 | arbor.PUT(w, GigsURL+r.URL.String(), GigFormat, "", r) 125 | } 126 | 127 | func DeleteClaim(w http.ResponseWriter, r *http.Request) { 128 | arbor.DELETE(w, GigsURL+r.URL.String(), GigFormat, "", r) 129 | } 130 | -------------------------------------------------------------------------------- /services/groups.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const GroupsURL string = config.GroupsURL 22 | 23 | //Service Data Type 24 | const GroupsFormat string = "JSON" 25 | 26 | //API Interface 27 | var GroupsRoutes = arbor.RouteCollection{ 28 | arbor.Route{ 29 | "GetGroupTypes", 30 | "GET", 31 | "/groups", 32 | GetGroupTypes, 33 | }, 34 | arbor.Route{ 35 | "GetGroups", 36 | "GET", 37 | "/groups/{groupType}", 38 | GetGroups, 39 | }, 40 | arbor.Route{ 41 | "GetGroup", 42 | "GET", 43 | "/groups/{groupType}/{groupName}", 44 | GetGroup, 45 | }, 46 | arbor.Route{ 47 | "IsGroupMember", 48 | "GET", 49 | "/groups/{groupType}/{groupName}?isMember={netid}", 50 | IsGroupMember, 51 | }, 52 | } 53 | 54 | // arbor.Route handler 55 | func GetGroupTypes(w http.ResponseWriter, r *http.Request) { 56 | arbor.GET(w, GroupsURL+r.URL.String(), GroupsFormat, "", r) 57 | } 58 | 59 | func GetGroups(w http.ResponseWriter, r *http.Request) { 60 | arbor.GET(w, GroupsURL+r.URL.String(), GroupsFormat, "", r) 61 | } 62 | 63 | func GetGroup(w http.ResponseWriter, r *http.Request) { 64 | arbor.GET(w, GroupsURL+r.URL.String(), GroupsFormat, "", r) 65 | } 66 | 67 | func IsGroupMember(w http.ResponseWriter, r *http.Request) { 68 | arbor.GET(w, GroupsURL+r.URL.String(), GroupsFormat, "", r) 69 | } 70 | -------------------------------------------------------------------------------- /services/hardware.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const HardwareURL string = config.HardwareURL 22 | 23 | //Service Data Type 24 | const HardwareFormat string = "JSON" 25 | 26 | //API Interface 27 | var HardwareRoutes = arbor.RouteCollection{ 28 | arbor.Route{ 29 | "NewItem", 30 | "POST", 31 | "/items/{id}", 32 | NewSession, 33 | }, 34 | arbor.Route{ 35 | "UpdateItem", 36 | "PUT", 37 | "/items/{id}", 38 | EndUsersSessions, 39 | }, 40 | arbor.Route{ 41 | "DeleteItem", 42 | "DELETE", 43 | "/item/{id}", 44 | GetAuthenticatedUser, 45 | }, 46 | } 47 | 48 | // arbor.Route handler 49 | func NewItem(w http.ResponseWriter, r *http.Request) { 50 | arbor.POST(w, HardwareURL+r.URL.String(), HardwareFormat, "", r) 51 | } 52 | 53 | func DeleteItem(w http.ResponseWriter, r *http.Request) { 54 | arbor.DELETE(w, HardwareURL+r.URL.String(), HardwareFormat, "", r) 55 | } 56 | 57 | func UpdateItem(w http.ResponseWriter, r *http.Request) { 58 | arbor.PUT(w, HardwareURL+r.URL.String(), HardwareFormat, "", r) 59 | } 60 | -------------------------------------------------------------------------------- /services/memes.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const MemesURL string = config.MemesURL 22 | 23 | //Service Data Type 24 | const MemeFormat string = "JSON" 25 | 26 | //API Interface 27 | var MemeRoutes = arbor.RouteCollection{ 28 | arbor.Route{ 29 | "ListMemes", 30 | "GET", 31 | "/memes", 32 | ListMemes, 33 | }, 34 | arbor.Route{ 35 | "NewMeme", 36 | "POST", 37 | "/memes", 38 | NewMeme, 39 | }, 40 | arbor.Route{ 41 | "MemeInfo", 42 | "GET", 43 | "/memes/{meme_id}", 44 | MemeInfo, 45 | }, 46 | arbor.Route{ 47 | "DeleteMeme", 48 | "DELETE", 49 | "/memes/{meme_id}", 50 | DeleteMeme, 51 | }, 52 | arbor.Route{ 53 | "ApproveMeme", 54 | "PUT", 55 | "/memes/{meme_id}/approve", 56 | ApproveMeme, 57 | }, 58 | arbor.Route{ 59 | "CastMemeVote", 60 | "PUT", 61 | "/memes/{meme_id}/vote", 62 | CastMemeVote, 63 | }, 64 | arbor.Route{ 65 | "DeleteMemeVote", 66 | "DELETE", 67 | "/memes/{meme_id}/vote", 68 | DeleteMemeVote, 69 | }, 70 | arbor.Route{ 71 | "GetRandomMeme", 72 | "GET", 73 | "/memes/random", 74 | GetRandomMeme, 75 | }, 76 | } 77 | 78 | // arbor.Route handler 79 | func ListMemes(w http.ResponseWriter, r *http.Request) { 80 | arbor.GET(w, MemesURL+r.URL.String(), MemeFormat, "", r) 81 | } 82 | 83 | func NewMeme(w http.ResponseWriter, r *http.Request) { 84 | arbor.POST(w, MemesURL+r.URL.String(), MemeFormat, "", r) 85 | } 86 | 87 | func MemeInfo(w http.ResponseWriter, r *http.Request) { 88 | arbor.GET(w, MemesURL+r.URL.String(), MemeFormat, "", r) 89 | } 90 | 91 | func DeleteMeme(w http.ResponseWriter, r *http.Request) { 92 | arbor.DELETE(w, MemesURL+r.URL.String(), MemeFormat, "", r) 93 | } 94 | 95 | func ApproveMeme(w http.ResponseWriter, r *http.Request) { 96 | arbor.PUT(w, MemesURL+r.URL.String(), MemeFormat, "", r) 97 | } 98 | 99 | func CastMemeVote(w http.ResponseWriter, r *http.Request) { 100 | arbor.PUT(w, MemesURL+r.URL.String(), MemeFormat, "", r) 101 | } 102 | 103 | func DeleteMemeVote(w http.ResponseWriter, r *http.Request) { 104 | arbor.DELETE(w, MemesURL+r.URL.String(), MemeFormat, "", r) 105 | } 106 | 107 | func GetRandomMeme(w http.ResponseWriter, r *http.Request) { 108 | arbor.GET(w, MemesURL+r.URL.String(), MemeFormat, "", r) 109 | } 110 | -------------------------------------------------------------------------------- /services/merch.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const MerchURL string = config.MerchURL 22 | 23 | //Service Data Type 24 | const MerchFormat string = "JSON" 25 | 26 | //API Interface 27 | var MerchRoutes = arbor.RouteCollection{ 28 | arbor.Route{ 29 | "GetMerchLocations", 30 | "GET", 31 | "/merch/locations", 32 | GetMerchLocations, 33 | }, 34 | arbor.Route{ 35 | "GetMerchItemAtLocation", 36 | "GET", 37 | "/merch/locations/{location}", 38 | GetMerchItemAtLocation, 39 | }, 40 | arbor.Route{ 41 | "ClearMerchItemAtLocation", 42 | "PUT", 43 | "/merch/locations/{location}", 44 | ClearMerchItemAtLocation, 45 | }, 46 | arbor.Route{ 47 | "GetMerchUsers", 48 | "GET", 49 | "/merch/users", 50 | GetMerchUsers, 51 | }, 52 | arbor.Route{ 53 | "GetMerchUserByNetid", 54 | "GET", 55 | "/merch/users/{netid}", 56 | GetMerchUserByNetid, 57 | }, 58 | arbor.Route{ 59 | "GetMerchUserByPin", 60 | "POST", 61 | "/merch/users/pins", 62 | GetMerchUserByPin, 63 | }, 64 | arbor.Route{ 65 | "CreateMerchTransaction", 66 | "POST", 67 | "/merch/transactions", 68 | CreateMerchTransaction, 69 | }, 70 | arbor.Route{ 71 | "GetItems", 72 | "GET", 73 | "/merch/items", 74 | GetItems, 75 | }, 76 | arbor.Route{ 77 | "CreateMerch", 78 | "POST", 79 | "/merch/items", 80 | CreateMerch, 81 | }, 82 | arbor.Route{ 83 | "GetMerch", 84 | "GET", 85 | "/merch/items/{id}", 86 | GetMerch, 87 | }, 88 | arbor.Route{ 89 | "UpdateMerch", 90 | "PUT", 91 | "/merch/items/{id}", 92 | UpdateMerch, 93 | }, 94 | arbor.Route{ 95 | "DeleteMerch", 96 | "DELETE", 97 | "/merch/items/{id}", 98 | DeleteMerch, 99 | }, 100 | } 101 | 102 | //Route handler 103 | func GetMerchLocations(w http.ResponseWriter, r *http.Request) { 104 | arbor.GET(w, MerchURL+r.URL.String(), MerchFormat, "", r) 105 | } 106 | 107 | func GetMerchItemAtLocation(w http.ResponseWriter, r *http.Request) { 108 | arbor.GET(w, MerchURL+r.URL.String(), MerchFormat, "", r) 109 | } 110 | 111 | func ClearMerchItemAtLocation(w http.ResponseWriter, r *http.Request) { 112 | arbor.PUT(w, MerchURL+r.URL.String(), MerchFormat, "", r) 113 | } 114 | 115 | func GetMerchUsers(w http.ResponseWriter, r *http.Request) { 116 | arbor.GET(w, MerchURL+r.URL.String(), MerchFormat, "", r) 117 | } 118 | 119 | func GetMerchUserByNetid(w http.ResponseWriter, r *http.Request) { 120 | arbor.GET(w, MerchURL+r.URL.String(), MerchFormat, "", r) 121 | } 122 | 123 | func GetMerchUserByPin(w http.ResponseWriter, r *http.Request) { 124 | arbor.POST(w, MerchURL+r.URL.String(), MerchFormat, "", r) 125 | } 126 | 127 | func CreateMerchTransaction(w http.ResponseWriter, r *http.Request) { 128 | arbor.POST(w, MerchURL+r.URL.String(), MerchFormat, "", r) 129 | } 130 | 131 | func GetItems(w http.ResponseWriter, r *http.Request) { 132 | arbor.GET(w, MerchURL+r.URL.String(), MerchFormat, "", r) 133 | } 134 | 135 | func CreateMerch(w http.ResponseWriter, r *http.Request) { 136 | arbor.POST(w, MerchURL+r.URL.String(), MerchFormat, "", r) 137 | } 138 | 139 | func GetMerch(w http.ResponseWriter, r *http.Request) { 140 | arbor.GET(w, MerchURL+r.URL.String(), MerchFormat, "", r) 141 | } 142 | 143 | func UpdateMerch(w http.ResponseWriter, r *http.Request) { 144 | arbor.PUT(w, MerchURL+r.URL.String(), MerchFormat, "", r) 145 | } 146 | 147 | func DeleteMerch(w http.ResponseWriter, r *http.Request) { 148 | arbor.DELETE(w, MerchURL+r.URL.String(), MerchFormat, "", r) 149 | } 150 | -------------------------------------------------------------------------------- /services/notification.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const NotificationURL string = config.NotificationURL 22 | 23 | //Service Data Type 24 | const NotificationFormat string = "JSON" 25 | 26 | //API Interface 27 | var NotificationRoutes = arbor.RouteCollection{ 28 | arbor.Route{ 29 | "PostNotification", 30 | "POST", 31 | "/notification", 32 | PostNotification, 33 | }, 34 | } 35 | 36 | // arbor.Route handler 37 | func PostNotification(w http.ResponseWriter, r *http.Request) { 38 | arbor.POST(w, NotificationURL+r.URL.String(), NotificationFormat, "", r) 39 | } 40 | -------------------------------------------------------------------------------- /services/quotes.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const QuotesURL string = config.QuotesURL 22 | 23 | //Service Data Type 24 | const QuoteFormat string = "JSON" 25 | 26 | //API Interface 27 | var QuotesRoutes = arbor.RouteCollection{ 28 | arbor.Route{ 29 | "GetAllQuotes", 30 | "GET", 31 | "/quotes", 32 | GetAllQuotes, 33 | }, 34 | arbor.Route{ 35 | "DeleteQuote", 36 | "DELETE", 37 | "/quotes/{id}", 38 | DeleteQuote, 39 | }, 40 | arbor.Route{ 41 | "GetQuote", 42 | "GET", 43 | "/quotes/{id}", 44 | GetQuote, 45 | }, 46 | arbor.Route{ 47 | "CastVote", 48 | "POST", 49 | "/quotes/{id}/vote", 50 | CastVote, 51 | }, 52 | arbor.Route{ 53 | "ApproveQuote", 54 | "PUT", 55 | "/quotes/{id}/approve", 56 | ApproveQuote, 57 | }, 58 | arbor.Route{ 59 | "DeleteVote", 60 | "DELETE", 61 | "/quotes/{id}/vote", 62 | DeleteVote, 63 | }, 64 | arbor.Route{ 65 | "CreateQuote", 66 | "POST", 67 | "/quotes", 68 | CreateQuote, 69 | }, 70 | arbor.Route{ 71 | "UpdateQuote", 72 | "PUT", 73 | "/quotes/{id}", 74 | UpdateQuote, 75 | }, 76 | } 77 | 78 | // arbor.Route handler 79 | func GetAllQuotes(w http.ResponseWriter, r *http.Request) { 80 | arbor.GET(w, QuotesURL+r.URL.String(), QuoteFormat, "", r) 81 | } 82 | 83 | func DeleteQuote(w http.ResponseWriter, r *http.Request) { 84 | arbor.DELETE(w, QuotesURL+r.URL.String(), QuoteFormat, "", r) 85 | } 86 | 87 | func GetQuote(w http.ResponseWriter, r *http.Request) { 88 | arbor.GET(w, QuotesURL+r.URL.String(), QuoteFormat, "", r) 89 | } 90 | 91 | func CreateQuote(w http.ResponseWriter, r *http.Request) { 92 | arbor.POST(w, QuotesURL+r.URL.String(), QuoteFormat, "", r) 93 | } 94 | 95 | func CastVote(w http.ResponseWriter, r *http.Request) { 96 | arbor.POST(w, QuotesURL+r.URL.String(), QuoteFormat, "", r) 97 | } 98 | 99 | func ApproveQuote(w http.ResponseWriter, r *http.Request) { 100 | arbor.PUT(w, QuotesURL+r.URL.String(), QuoteFormat, "", r) 101 | } 102 | 103 | func DeleteVote(w http.ResponseWriter, r *http.Request) { 104 | arbor.DELETE(w, QuotesURL+r.URL.String(), QuoteFormat, "", r) 105 | } 106 | 107 | func UpdateQuote(w http.ResponseWriter, r *http.Request) { 108 | arbor.PUT(w, QuotesURL+r.URL.String(), QuoteFormat, "", r) 109 | } 110 | -------------------------------------------------------------------------------- /services/recruiters.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const RecruiterURL string = config.RecruiterURL 22 | 23 | //Service Data Type 24 | const RecruiterFormat string = "JSON" 25 | 26 | //API Interface 27 | var RecruitersRoutes = arbor.RouteCollection{ 28 | arbor.Route{ 29 | "GetJobs", 30 | "GET", 31 | "/jobs", 32 | GetJobs, 33 | }, 34 | arbor.Route{ 35 | "CreateJob", 36 | "POST", 37 | "/jobs", 38 | CreateJob, 39 | }, 40 | arbor.Route{ 41 | "ApproveJob", 42 | "PUT", 43 | "/jobs/{job_id}/approve", 44 | ApproveJob, 45 | }, 46 | arbor.Route{ 47 | "DeleteJob", 48 | "DELETE", 49 | "/jobs/{job_id}", 50 | DeleteJob, 51 | }, 52 | arbor.Route{ 53 | "GetRecruiters", 54 | "GET", 55 | "/recruiters", 56 | GetRecruiters, 57 | }, 58 | arbor.Route{ 59 | "RecruiterLogin", 60 | "POST", 61 | "/recruiters/login", 62 | RecruiterLogin, 63 | }, 64 | arbor.Route{ 65 | "CreateRecruiter", 66 | "POST", 67 | "/recruiters", 68 | CreateRecruiter, 69 | }, 70 | arbor.Route{ 71 | "GetRecruiter", 72 | "GET", 73 | "/recruiters/{recruiter_id}", 74 | GetRecruiter, 75 | }, 76 | arbor.Route{ 77 | "RenewRecruiter", 78 | "PUT", 79 | "/recruiters/{recruiter_id}/renew", 80 | RenewRecruiter, 81 | }, 82 | arbor.Route{ 83 | "ResetAllRecruiters", 84 | "POST", 85 | "/recruiters/reset", 86 | ResetAllRecruiters, 87 | }, 88 | arbor.Route{ 89 | "UpdateRecruiter", 90 | "PUT", 91 | "/recruiters/{recruiter_id}", 92 | UpdateRecruiter, 93 | }, 94 | arbor.Route{ 95 | "ResetRecruiter", 96 | "POST", 97 | "/recruiters/reset_password", 98 | ResetRecruiter, 99 | }, 100 | arbor.Route{ 101 | "GetRecruiterInvite", 102 | "GET", 103 | "/recruiters/{recruiter_id}/invite", 104 | GetRecruiterInvite, 105 | }, 106 | arbor.Route{ 107 | "SendRecruiterInvite", 108 | "POST", 109 | "/recruiters/{recruiter_id}/invite", 110 | SendRecruiterInvite, 111 | }, 112 | arbor.Route{ 113 | "ResetRecruiterInvite", 114 | "POST", 115 | "/recruiters/invite", 116 | ResetRecruiterInvite, 117 | }, 118 | arbor.Route{ 119 | "DeleteRecruiter", 120 | "DELETE", 121 | "/recruiters/{recruiter_id}", 122 | DeleteRecruiter, 123 | }, 124 | arbor.Route{ 125 | "GetStudents", 126 | "GET", 127 | "/students", 128 | GetStudents, 129 | }, 130 | arbor.Route{ 131 | "CreateStudent", 132 | "POST", 133 | "/students", 134 | CreateStudent, 135 | }, 136 | arbor.Route{ 137 | "ApproveStudent", 138 | "PUT", 139 | "/students/{netid}/approve", 140 | ApproveStudent, 141 | }, 142 | arbor.Route{ 143 | "GetStudent", 144 | "GET", 145 | "/students/{netid}", 146 | GetStudent, 147 | }, 148 | arbor.Route{ 149 | "DeleteStudent", 150 | "DELETE", 151 | "/students/{netid}", 152 | DeleteStudent, 153 | }, 154 | } 155 | 156 | // arbor.Route handler 157 | func GetJobs(w http.ResponseWriter, r *http.Request) { 158 | arbor.GET(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 159 | } 160 | 161 | func CreateJob(w http.ResponseWriter, r *http.Request) { 162 | arbor.POST(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 163 | } 164 | 165 | func ApproveJob(w http.ResponseWriter, r *http.Request) { 166 | arbor.PUT(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 167 | } 168 | 169 | func DeleteJob(w http.ResponseWriter, r *http.Request) { 170 | arbor.DELETE(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 171 | } 172 | 173 | func GetRecruiters(w http.ResponseWriter, r *http.Request) { 174 | arbor.GET(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 175 | } 176 | 177 | func RecruiterLogin(w http.ResponseWriter, r *http.Request) { 178 | arbor.POST(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 179 | } 180 | 181 | func GetRecruiter(w http.ResponseWriter, r *http.Request) { 182 | arbor.GET(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 183 | } 184 | 185 | func CreateRecruiter(w http.ResponseWriter, r *http.Request) { 186 | arbor.POST(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 187 | } 188 | 189 | func RenewRecruiter(w http.ResponseWriter, r *http.Request) { 190 | arbor.PUT(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 191 | } 192 | 193 | func ResetAllRecruiters(w http.ResponseWriter, r *http.Request) { 194 | arbor.POST(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 195 | } 196 | 197 | func UpdateRecruiter(w http.ResponseWriter, r *http.Request) { 198 | arbor.PUT(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 199 | } 200 | 201 | func ResetRecruiter(w http.ResponseWriter, r *http.Request) { 202 | arbor.POST(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 203 | } 204 | 205 | func GetRecruiterInvite(w http.ResponseWriter, r *http.Request) { 206 | arbor.GET(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 207 | } 208 | 209 | func SendRecruiterInvite(w http.ResponseWriter, r *http.Request) { 210 | arbor.POST(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 211 | } 212 | 213 | func ResetRecruiterInvite(w http.ResponseWriter, r *http.Request) { 214 | arbor.POST(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 215 | } 216 | 217 | func DeleteRecruiter(w http.ResponseWriter, r *http.Request) { 218 | arbor.DELETE(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 219 | } 220 | 221 | func CreateStudent(w http.ResponseWriter, r *http.Request) { 222 | arbor.POST(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 223 | } 224 | 225 | func ApproveStudent(w http.ResponseWriter, r *http.Request) { 226 | arbor.PUT(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 227 | } 228 | 229 | func GetStudents(w http.ResponseWriter, r *http.Request) { 230 | arbor.GET(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 231 | } 232 | 233 | func GetStudent(w http.ResponseWriter, r *http.Request) { 234 | arbor.GET(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 235 | } 236 | 237 | func DeleteStudent(w http.ResponseWriter, r *http.Request) { 238 | arbor.DELETE(w, RecruiterURL+r.URL.String(), RecruiterFormat, "", r) 239 | } 240 | -------------------------------------------------------------------------------- /services/request.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 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 | } 70 | -------------------------------------------------------------------------------- /services/services.go: -------------------------------------------------------------------------------- 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 | "fmt" 15 | "net/http" 16 | 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | var Routes = arbor.RouteCollection{ 21 | arbor.Route{ 22 | "Index", 23 | "GET", 24 | "/", 25 | Index, 26 | }, 27 | } 28 | 29 | func Index(w http.ResponseWriter, r *http.Request) { 30 | fmt.Fprint(w, "I AM GROOT!\n") 31 | } 32 | 33 | func RegisterAPIs() arbor.RouteCollection { 34 | Routes = append(Routes, ADRoutes...) 35 | Routes = append(Routes, AuthRoutes...) 36 | Routes = append(Routes, CreditsRoutes...) 37 | Routes = append(Routes, EventsRoutes...) 38 | Routes = append(Routes, GigsRoutes...) 39 | Routes = append(Routes, GroupsRoutes...) 40 | Routes = append(Routes, HardwareRoutes...) 41 | Routes = append(Routes, MemeRoutes...) 42 | Routes = append(Routes, MerchRoutes...) 43 | Routes = append(Routes, NotificationRoutes...) 44 | Routes = append(Routes, QuotesRoutes...) 45 | Routes = append(Routes, RecruitersRoutes...) 46 | Routes = append(Routes, UsersRoutes...) 47 | return Routes 48 | } 49 | -------------------------------------------------------------------------------- /services/users.go: -------------------------------------------------------------------------------- 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/groot-api-gateway/config" 17 | "github.com/arbor-dev/arbor" 18 | ) 19 | 20 | //Location 21 | const UsersURL string = config.UsersURL 22 | 23 | //Service Data Type 24 | const UsersFormat string = "JSON" 25 | 26 | //API Interface 27 | var UsersRoutes = arbor.RouteCollection{ 28 | arbor.Route{ 29 | "GetUsers", 30 | "GET", 31 | "/users", 32 | GetUsers, 33 | }, 34 | arbor.Route{ 35 | "IsMember", 36 | "GET", 37 | "/users/{netid}/is_member", 38 | IsMember, 39 | }, 40 | arbor.Route{ 41 | "NewUser", 42 | "POST", 43 | "/users", 44 | NewUser, 45 | }, 46 | arbor.Route{ 47 | "ConfirmUser", 48 | "PUT", 49 | "/users/{user_id}/paid", 50 | ConfirmUser, 51 | }, 52 | arbor.Route{ 53 | "DeleteUser", 54 | "DELETE", 55 | "/users/{user_id}", 56 | DeleteUser, 57 | }, 58 | arbor.Route{ 59 | "UsersLogin", 60 | "POST", 61 | "/users/login", 62 | UsersLogin, 63 | }, 64 | arbor.Route{ 65 | "UsersLogout", 66 | "POST", 67 | "/users/logout", 68 | UsersLogout, 69 | }, 70 | } 71 | 72 | // arbor.Route handler 73 | func GetUsers(w http.ResponseWriter, r *http.Request) { 74 | arbor.GET(w, UsersURL+r.URL.String(), UsersFormat, "", r) 75 | } 76 | 77 | func IsMember(w http.ResponseWriter, r *http.Request) { 78 | arbor.GET(w, UsersURL+r.URL.String(), UsersFormat, "", r) 79 | } 80 | 81 | func NewUser(w http.ResponseWriter, r *http.Request) { 82 | arbor.POST(w, UsersURL+r.URL.String(), UsersFormat, "", r) 83 | } 84 | 85 | func ConfirmUser(w http.ResponseWriter, r *http.Request) { 86 | arbor.PUT(w, UsersURL+r.URL.String(), UsersFormat, "", r) 87 | } 88 | 89 | func DeleteUser(w http.ResponseWriter, r *http.Request) { 90 | arbor.DELETE(w, UsersURL+r.URL.String(), UsersFormat, "", r) 91 | } 92 | 93 | func UsersLogin(w http.ResponseWriter, r *http.Request) { 94 | arbor.POST(w, UsersURL+r.URL.String(), UsersFormat, "", r) 95 | } 96 | 97 | func UsersLogout(w http.ResponseWriter, r *http.Request) { 98 | arbor.POST(w, UsersURL+r.URL.String(), UsersFormat, "", r) 99 | } 100 | --------------------------------------------------------------------------------