motiv-labs / janus

An API Gateway written in Go
https://hellofresh.gitbooks.io/janus
MIT License
2.79k stars 317 forks source link

Can't follow quickstart #335

Closed denysvitali closed 6 years ago

denysvitali commented 6 years ago

I'm pretty new to Janus, therefore I'm trying to follow the quick start - but I have some problems with it. Everything seems to work until I try to create an endpoint, as per guide

Reproduction Steps:

  1. ACCESS_TOKEN=$(http --json POST gw1.sd:8081/login username=admin password=admin | jq .access_token -r)
  2. http --json GET gw1.sd:8081/apis "Authorization: Bearer $ACCESS_TOKEN"
    
    dvitali@denvit-ws1:janus/config $ http --json GET gw1.sd:8081/apis "Authorization: Bearer $ACCESS_TOKEN"                   
    HTTP/1.1 200 OK
    Content-Encoding: gzip
    Content-Length: 29
    Content-Type: application/json
    Date: Fri, 13 Jul 2018 13:19:45 GMT
    Vary: Origin

null

3. Create the `example.json` file:

dvitali@denvit-ws1:janus/config $ cat example.json | jq .
{ "name": "my-endpoint", "active": true, "proxy": { "listen_path": "/example/*", "upstreams": { "balancing": "roundrobin", "targets": [ { "target": "http://www.mocky.io/v2/595625d22900008702cd71e8" } ] }, "methods": [ "GET" ] } }

4. `http -v --json POST gw1.sd:8081/apis "Authorization: Bearer $ACCESS_TOKEN" < example.json`

(hangs)

**Expected behavior:**

The endpoint gets created

**Observed behavior:**

Connection hangs, the endpoint is not created

**Janus version:** 

dvitali@sd-arch-gw1:~ $ docker exec -it janus /janus version janus 0.0.0-dev

dvitali@sd-arch-gw1:~ $ docker images quay.io/hellofresh/janus REPOSITORY TAG IMAGE ID CREATED SIZE quay.io/hellofresh/janus latest 737d50c89194 3 hours ago 30.6MB

**OS and version:**

Arch Linux

dvitali@sd-arch-gw1:~ $ uname -sr Linux 4.17.5-1-ARCH


**Docker Versions:**

dvitali@sd-arch-gw1:~ $ pacman -Q docker docker-compose httpie docker 1:18.05.0-2 docker-compose 1.21.2-1


**HTTPie version:**

dvitali@denvit-ws1:janus/config $ http --version
0.9.9


Relevant log output:

{"code":200,"duration":0,"duration-fmt":"842.891µs","host":"gw1.sd:8081","level":"info","method":"POST","msg":"Completed handling request","referer":"","remote-addr":"192.168.56.1:41344","request":"/login","request-id":"","time":"2018-07-13T13:19:38Z","user-agent":"HTTPie/0.9.9"} {"code":200,"duration":0,"duration-fmt":"301.341µs","host":"gw1.sd:8081","level":"info","method":"GET","msg":"Completed handling request","referer":"","remote-addr":"192.168.56.1:41350","request":"/apis","request-id":"","time":"2018-07-13T13:19:45Z","user-agent":"HTTPie/0.9.9"}

vgarvardt commented 6 years ago

Hello @denysvitali. Thank you for reporting! I already found and fixed an issue because of your report - version was missing in the recent build. Will try to reproduce your issue as well and either fix the docs or the app.

denysvitali commented 6 years ago

Thank you! Let me know when a newer Docker build is available, so that I can try to follow the quickstart again and report back if the issue is fixed :+1:

vgarvardt commented 6 years ago

Fixed one more minor issue based on your report - empty definitions list will be returned as empty JSON array [] instead of null. But I was not able to reproduce your problem - everything seems to be working fine for me:

$ http -v --json POST localhost:8081/apis "Authorization: Bearer $ACCESS_TOKEN" < example.json
POST /apis HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MzI2ODU2MTAsImlhdCI6MTUzMjY4MjAxMH0.9LTug52tCcENAobq086lbXkzk-Irmuyh6eCGE6zZCNs
Connection: keep-alive
Content-Length: 309
Content-Type: application/json
Host: localhost:8081
User-Agent: HTTPie/0.9.9

{
    "active": true,
    "name": "my-endpoint",
    "proxy": {
        "listen_path": "/example/*",
        "methods": [
            "GET"
        ],
        "upstreams": {
            "balancing": "roundrobin",
            "targets": [
                {
                    "target": "http://www.mocky.io/v2/595625d22900008702cd71e8"
                }
            ]
        }
    }
}

HTTP/1.1 201 Created
Content-Length: 0
Date: Fri, 27 Jul 2018 09:38:58 GMT
Location: /apis/my-endpoint
Vary: Origin

My OS is MacOS 10.13.6 with latest Docker CE 18.06.0-ce-mac69 (26398) running.

I'm closing the issue, but if you still will be able to reproduce the issue - feel free to reopen it and we'll try to reproduce the issue together, probably by adding some debug logs.