Skip to content

Commit

Permalink
Fix import of httputils and add travis CI
Browse files Browse the repository at this point in the history
**What**
- Fix a broken rename in the proxy code, it was referenceing `httputils`
instead of the correct `httputil`
- Add a travis config to help ensure that the project is compilable

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
  • Loading branch information
LucasRoesler authored and alexellis committed Jul 6, 2019
1 parent 0ca8ae6 commit a04c03d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
@@ -0,0 +1,4 @@
language: go
go_import_path: github.com/openfaas/faas-provider
script:
- make test
4 changes: 4 additions & 0 deletions Makefile
@@ -1,2 +1,6 @@
build:
docker build -t faas-provider .


test :
go test -cover ./...
10 changes: 5 additions & 5 deletions proxy/proxy.go
Expand Up @@ -29,7 +29,7 @@ import (
"time"

"github.com/gorilla/mux"
"github.com/openfaas/faas-provider/httputils"
"github.com/openfaas/faas-provider/httputil"
)

const (
Expand Down Expand Up @@ -112,21 +112,21 @@ func proxyRequest(w http.ResponseWriter, originalReq *http.Request, proxyClient
pathVars := mux.Vars(originalReq)
functionName := pathVars["name"]
if functionName == "" {
httputils.Errorf(w, http.StatusBadRequest, errMissingFunctionName)
httputil.Errorf(w, http.StatusBadRequest, errMissingFunctionName)
return
}

functionAddr, resolveErr := resolver.Resolve(functionName)
if resolveErr != nil {
// TODO: Should record the 404/not found error in Prometheus.
log.Printf("resolver error: cannot find %s: %s\n", functionName, resolveErr.Error())
httputils.Errorf(w, http.StatusNotFound, "Cannot find service: %s.", functionName)
httputil.Errorf(w, http.StatusNotFound, "Cannot find service: %s.", functionName)
return
}

proxyReq, err := buildProxyRequest(originalReq, functionAddr, pathVars["params"])
if err != nil {
httputils.Errorf(w, http.StatusInternalServerError, "Failed to resolve service: %s.", functionName)
httputil.Errorf(w, http.StatusInternalServerError, "Failed to resolve service: %s.", functionName)
return
}
if proxyReq.Body != nil {
Expand All @@ -140,7 +140,7 @@ func proxyRequest(w http.ResponseWriter, originalReq *http.Request, proxyClient
if err != nil {
log.Printf("error with proxy request to: %s, %s\n", proxyReq.URL.String(), err.Error())

httputils.Errorf(w, http.StatusInternalServerError, "Can't reach service for: %s.", functionName)
httputil.Errorf(w, http.StatusInternalServerError, "Can't reach service for: %s.", functionName)
return
}

Expand Down

0 comments on commit a04c03d

Please sign in to comment.