net/http
Here is my compose file:
version: "2"
services:
staticfiles:
build: ./files
volumes:
- /public
- /views
api:
build: ./api
environment:
- PORT=8080
- BASE_URL=https://example.org
- AUTH_HOST=auth
- AUTH_PORT=8080
- VIEW_DIR=/views
- PUBLIC_DIR=/public
ports:
- "80:8080"
volumes_from:
- staticfiles:ro
links:
- auth
depends_on:
- staticfiles
db:
build: ./postgres
environment:
- POSTGRES_USER=inheritor
- POSTGRES_DB=inheritor
auth:
build: ./auth
expose:
- "8080"
environment:
- PORT=8080
- DB_USER=inheritor
- DB_NAME=inheritor
- DB_HOST=db
- DB_Port=5432
links:
- db
ping authcurl -X Post http://auth:8080/validatedial address tcp i/o timeout
var (
authString = "http://" + env.AuthHost + ":" + env.AuthPort
)
//ValidateToken validates a token using the session in DB
func ValidateToken(req *model.ValidateRequest) (*model.JWTClaims, error) {
client := new(http.Client)
api := authString + "/validate"
cont, err := model.Jsonify(req)
if err != nil {
return nil, exception.NewInternalError("Could not turn the request into a json object.")
}
request, err := http.NewRequest("POST", api, bytes.NewBuffer(cont))
if err != nil {
return nil, exception.NewInternalError("Could not create request: " + err.Error())
}
request.Header.Set("Content-type", "application/json")
response, err := client.Do(request)
if err != nil {
return nil, exception.NewInternalError("Could not make the request: " + err.Error())
}
defer response.Body.Close()
res := new(model.AuthResponse)
res.Claims = new(model.JWTClaims)
decoder := json.NewDecoder(response.Body)
err = decoder.Decode(&res)
spew.Dump(response.Body)
if err != nil {
return nil, exception.NewInternalError("Could not parse response back from auth service. " + err.Error())
}
if response.StatusCode != http.StatusOK {
return nil, exception.NewInvalidJWTError(res.Error)
}
return res.Claims, nil
}
client.Do(request)
env.AuthHostAUTH_HOSTenv.AuthPortAuth_PORT
Much help is appreciated.
If it helps I am running MacOSX.
Client:
Version: 1.12.0-rc4
API version: 1.24
Go version: go1.6.2
Git commit: e4a0dbc
Built: Wed Jul 13 03:28:51 2016
OS/Arch: darwin/amd64
Experimental: true
Server:
Version: 1.12.0-rc4
API version: 1.24
Go version: go1.6.2
Git commit: e4a0dbc
Built: Wed Jul 13 03:28:51 2016
OS/Arch: linux/amd64
Experimental: true
Dockerfile
FROM golang:1.6
RUN mkdir -p /go/src/github.com/dixonwille/Inheritor/api
WORKDIR /go/src/github.com/dixonwille/Inheritor/api
COPY . /go/src/github.com/dixonwille/Inheritor/api
RUN go build -v -o Inheritor cmd/Inheritor/main.go
USER nobody
ENTRYPOINT ["./Inheritor"]
EDIT:
net.LookupHost(env.AuthHost)pingcurldocker inspect
EDIT:
Sorry for all the edits kind of trying to debug as the day goes.
authStringlocalhost
I have tried exposing a port on the host machine and accessing it with that port with no better luck (same hostname).
EDIT:
So it is a Mac only thing I assume. I cloned down the repo and ran on Windows 10 and I was able to connect to my auth service. Would this be Docker for Mac error? I am probably going to report it to them, but I would not consider this closed since it still is an issue for Mac users.