mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Replace FN_ROUTE with FN_PATH
This commit is contained in:
@@ -66,7 +66,7 @@ func TestCallConfigurationRequest(t *testing.T) {
|
|||||||
req.Header.Add("MYREALHEADER", "FOOLORD")
|
req.Header.Add("MYREALHEADER", "FOOLORD")
|
||||||
req.Header.Add("MYREALHEADER", "FOOPEASANT")
|
req.Header.Add("MYREALHEADER", "FOOPEASANT")
|
||||||
req.Header.Add("Content-Length", contentLength)
|
req.Header.Add("Content-Length", contentLength)
|
||||||
req.Header.Add("FN_ROUTE", "thewrongroute") // ensures that this doesn't leak out, should be overwritten
|
req.Header.Add("FN_PATH", "thewrongroute") // ensures that this doesn't leak out, should be overwritten
|
||||||
|
|
||||||
call, err := a.GetCall(
|
call, err := a.GetCall(
|
||||||
WithWriter(w), // XXX (reed): order matters [for now]
|
WithWriter(w), // XXX (reed): order matters [for now]
|
||||||
@@ -119,7 +119,7 @@ func TestCallConfigurationRequest(t *testing.T) {
|
|||||||
expectedBase := map[string]string{
|
expectedBase := map[string]string{
|
||||||
"FN_FORMAT": format,
|
"FN_FORMAT": format,
|
||||||
"FN_APP_NAME": appName,
|
"FN_APP_NAME": appName,
|
||||||
"FN_ROUTE": path,
|
"FN_PATH": path,
|
||||||
"FN_MEMORY": strconv.Itoa(memory),
|
"FN_MEMORY": strconv.Itoa(memory),
|
||||||
"FN_TYPE": typ,
|
"FN_TYPE": typ,
|
||||||
"APP_VAR": "FOO",
|
"APP_VAR": "FOO",
|
||||||
@@ -210,7 +210,7 @@ func TestCallConfigurationModel(t *testing.T) {
|
|||||||
env := map[string]string{
|
env := map[string]string{
|
||||||
"FN_FORMAT": format,
|
"FN_FORMAT": format,
|
||||||
"FN_APP_NAME": appName,
|
"FN_APP_NAME": appName,
|
||||||
"FN_ROUTE": path,
|
"FN_PATH": path,
|
||||||
"FN_MEMORY": strconv.Itoa(memory),
|
"FN_MEMORY": strconv.Itoa(memory),
|
||||||
"FN_TYPE": typ,
|
"FN_TYPE": typ,
|
||||||
"APP_VAR": "FOO",
|
"APP_VAR": "FOO",
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ func noOverrideVars(key string) bool {
|
|||||||
var overrideVars = map[string]bool{
|
var overrideVars = map[string]bool{
|
||||||
"FN_FORMAT": true,
|
"FN_FORMAT": true,
|
||||||
"FN_APP_NAME": true,
|
"FN_APP_NAME": true,
|
||||||
"FN_ROUTE": true,
|
"FN_PATH": true,
|
||||||
"FN_MEMORY": true,
|
"FN_MEMORY": true,
|
||||||
"FN_TYPE": true,
|
"FN_TYPE": true,
|
||||||
"FN_CALL_ID": true,
|
"FN_CALL_ID": true,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ You will also have access to a set of environment variables.
|
|||||||
|
|
||||||
* `FN_REQUEST_URL` - the full URL for the request ([parsing example](https://github.com/fnproject/fn/tree/master/examples/tutorial/params))
|
* `FN_REQUEST_URL` - the full URL for the request ([parsing example](https://github.com/fnproject/fn/tree/master/examples/tutorial/params))
|
||||||
* `FN_APP_NAME` - the name of the application that matched this route, eg: `myapp`
|
* `FN_APP_NAME` - the name of the application that matched this route, eg: `myapp`
|
||||||
* `FN_ROUTE` - the matched route, eg: `/hello`
|
* `FN_PATH` - the matched route, eg: `/hello`
|
||||||
* `FN_METHOD` - the HTTP method for the request, eg: `GET` or `POST`
|
* `FN_METHOD` - the HTTP method for the request, eg: `GET` or `POST`
|
||||||
* `FN_CALL_ID` - a unique ID for each function execution.
|
* `FN_CALL_ID` - a unique ID for each function execution.
|
||||||
* `FN_FORMAT` - a string representing one of the [function formats](function-format.md), currently either `default` or `http`. Default is `default`.
|
* `FN_FORMAT` - a string representing one of the [function formats](function-format.md), currently either `default` or `http`. Default is `default`.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
var noAuth = map[string]interface{}{}
|
var noAuth = map[string]interface{}{}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
request := fmt.Sprintf("%s %s", os.Getenv("FN_METHOD"), os.Getenv("FN_ROUTE"))
|
request := fmt.Sprintf("%s %s", os.Getenv("FN_METHOD"), os.Getenv("FN_PATH"))
|
||||||
|
|
||||||
dbURI := os.Getenv("DB")
|
dbURI := os.Getenv("DB")
|
||||||
if dbURI == "" {
|
if dbURI == "" {
|
||||||
@@ -36,7 +36,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GETTING TOKEN
|
// GETTING TOKEN
|
||||||
if os.Getenv("FN_ROUTE") == "/token" {
|
if os.Getenv("FN_PATH") == "/token" {
|
||||||
route.HandleToken(db)
|
route.HandleToken(db)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ docker rm test-mongo-func
|
|||||||
|
|
||||||
docker run -p 27017:27017 --name test-mongo-func -d mongo
|
docker run -p 27017:27017 --name test-mongo-func -d mongo
|
||||||
|
|
||||||
echo '{ "title": "My New Post", "body": "Hello world!", "user": "test" }' | docker run --rm -i -e FN_METHOD=POST -e FN_ROUTE=/posts -e DB=mongo:27017 --link test-mongo-func:mongo -e TEST=1 username/func-blog
|
echo '{ "title": "My New Post", "body": "Hello world!", "user": "test" }' | docker run --rm -i -e FN_METHOD=POST -e FN_PATH=/posts -e DB=mongo:27017 --link test-mongo-func:mongo -e TEST=1 username/func-blog
|
||||||
docker run --rm -i -e FN_METHOD=GET -e FN_ROUTE=/posts -e DB=mongo:27017 --link test-mongo-func:mongo -e TEST=1 username/func-blog
|
docker run --rm -i -e FN_METHOD=GET -e FN_PATH=/posts -e DB=mongo:27017 --link test-mongo-func:mongo -e TEST=1 username/func-blog
|
||||||
|
|
||||||
docker stop test-mongo-func
|
docker stop test-mongo-func
|
||||||
docker rm test-mongo-func
|
docker rm test-mongo-func
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ e = ENV["FN_APP_NAME"]
|
|||||||
if e == nil || e == ''
|
if e == nil || e == ''
|
||||||
raise "No APP_NAME found"
|
raise "No APP_NAME found"
|
||||||
end
|
end
|
||||||
e = ENV["FN_ROUTE"]
|
e = ENV["FN_PATH"]
|
||||||
if e == nil || e == ''
|
if e == nil || e == ''
|
||||||
raise "No ROUTE found"
|
raise "No ROUTE found"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user