mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Change default API URL from localhost to 127.0.0.1 (#153)
* Change host from localhost to 127.0.0.1 * change unit tests to also use 127.0.0.1 instead of localhost
This commit is contained in:
committed by
C Cirello
parent
1ff480561a
commit
006c01c97e
@@ -169,15 +169,15 @@ func TestTasksrvURL(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
port, in, out string
|
port, in, out string
|
||||||
}{
|
}{
|
||||||
{"8080", "//localhost", "http://localhost:8080/tasks"},
|
{"8080", "//127.0.0.1", "http://127.0.0.1:8080/tasks"},
|
||||||
{"8080", "//localhost/", "http://localhost:8080/tasks"},
|
{"8080", "//127.0.0.1/", "http://127.0.0.1:8080/tasks"},
|
||||||
{"8080", "//localhost:8081", "http://localhost:8081/tasks"},
|
{"8080", "//127.0.0.1:8081", "http://127.0.0.1:8081/tasks"},
|
||||||
{"8080", "//localhost:8081/", "http://localhost:8081/tasks"},
|
{"8080", "//127.0.0.1:8081/", "http://127.0.0.1:8081/tasks"},
|
||||||
{"8080", "http://localhost", "http://localhost:8080/tasks"},
|
{"8080", "http://127.0.0.1", "http://127.0.0.1:8080/tasks"},
|
||||||
{"8080", "http://localhost/", "http://localhost:8080/tasks"},
|
{"8080", "http://127.0.0.1/", "http://127.0.0.1:8080/tasks"},
|
||||||
{"8080", "http://localhost:8081", "http://localhost:8081/tasks"},
|
{"8080", "http://127.0.0.1:8081", "http://127.0.0.1:8081/tasks"},
|
||||||
{"8080", "http://localhost:8081/", "http://localhost:8081/tasks"},
|
{"8080", "http://127.0.0.1:8081/", "http://127.0.0.1:8081/tasks"},
|
||||||
{"8080", "http://localhost:8081/endpoint", "http://localhost:8081/endpoint"},
|
{"8080", "http://127.0.0.1:8081/endpoint", "http://127.0.0.1:8081/endpoint"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func testRouter() *gin.Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func routerRequest(t *testing.T, router *gin.Engine, method, path string, body io.Reader) (*http.Request, *httptest.ResponseRecorder) {
|
func routerRequest(t *testing.T, router *gin.Engine, method, path string, body io.Reader) (*http.Request, *httptest.ResponseRecorder) {
|
||||||
req, err := http.NewRequest(method, "http://localhost:8080"+path, body)
|
req, err := http.NewRequest(method, "http://127.0.0.1:8080"+path, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test: Could not create %s request to %s: %v", method, path, err)
|
t.Fatalf("Test: Could not create %s request to %s: %v", method, path, err)
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ func routerRequest(t *testing.T, router *gin.Engine, method, path string, body i
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newRouterRequest(t *testing.T, method, path string, body io.Reader) (*http.Request, *httptest.ResponseRecorder) {
|
func newRouterRequest(t *testing.T, method, path string, body io.Reader) (*http.Request, *httptest.ResponseRecorder) {
|
||||||
req, err := http.NewRequest(method, "http://localhost:8080"+path, body)
|
req, err := http.NewRequest(method, "http://127.0.0.1:8080"+path, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test: Could not create %s request to %s: %v", method, path, err)
|
t.Fatalf("Test: Could not create %s request to %s: %v", method, path, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ info:
|
|||||||
description:
|
description:
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
# the domain of the service
|
# the domain of the service
|
||||||
host: "localhost:8080"
|
host: "127.0.0.1:8080"
|
||||||
# array of all schemes that your API supports
|
# array of all schemes that your API supports
|
||||||
schemes:
|
schemes:
|
||||||
- https
|
- https
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -35,7 +35,7 @@ func init() {
|
|||||||
viper.SetDefault(envMQ, fmt.Sprintf("bolt://%s/data/worker_mq.db", cwd))
|
viper.SetDefault(envMQ, fmt.Sprintf("bolt://%s/data/worker_mq.db", cwd))
|
||||||
viper.SetDefault(envDB, fmt.Sprintf("bolt://%s/data/bolt.db?bucket=funcs", cwd))
|
viper.SetDefault(envDB, fmt.Sprintf("bolt://%s/data/bolt.db?bucket=funcs", cwd))
|
||||||
viper.SetDefault(envPort, 8080)
|
viper.SetDefault(envPort, 8080)
|
||||||
viper.SetDefault(envAPIURL, fmt.Sprintf("http://localhost:%d", viper.GetInt(envPort)))
|
viper.SetDefault(envAPIURL, fmt.Sprintf("http://127.0.0.1:%d", viper.GetInt(envPort)))
|
||||||
viper.SetDefault(envNumAsync, 1)
|
viper.SetDefault(envNumAsync, 1)
|
||||||
viper.SetConfigName("config")
|
viper.SetConfigName("config")
|
||||||
viper.AddConfigPath(".")
|
viper.AddConfigPath(".")
|
||||||
|
|||||||
Reference in New Issue
Block a user