-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.go
37 lines (29 loc) · 906 Bytes
/
server.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
package api
import (
"net/http"
"os"
"github.com/aws/aws-lambda-go/lambda"
negroniadapter "github.com/awslabs/aws-lambda-go-api-proxy/negroni"
)
//"Global" variables.
var (
kitchenTable string = os.Getenv("KITCHTABLE")
tokenVerifyURL string = os.Getenv("TOKENURL")
AUTH_AUDIENCE string = os.Getenv("AUTH_AUDIENCE")
recipeTable string = os.Getenv("RECIPETABLE")
)
//InitServer gets and sets the routes for the http server before
//it starts listening. It is a function so we can use this or Lambda
//which requires a wrapper.
func InitServer() {
router := setRoutes()
http.ListenAndServe(":8080", router)
}
//InitServer gets and sets the routes for the http server before
//it starts listening. It also uses the AWS negroniadapter which
//is required for Lambda.
func InitLambda() {
router := setRoutes()
negroniLambda := *negroniadapter.New(router)
lambda.Start(negroniLambda)
}