motiv-labs / janus

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

Enable Discussions on This Repo? #496

Open davidrenne opened 6 months ago

davidrenne commented 6 months ago

Can you guys enable discussions on this repo so this doesnt have to go into an issue? You can just copy and paste this question into the issues or I will resubmit it if you are okay with enabling the new discussions feature.

I spent about 10-15 minutes just browsing docs, and I wanted to ask a question. All I see in examples and docs are configuration files for setting up the API gateway and static JSON files.

I feel like a really dumb golang engineer here asking this, but, how do you bind a dynamic API endpoint that does something like connect to a database to produce output that the user desires based on their data? Do I merely build my own http listener with standard REST like APIs and then use "targets" and janus will proxy the entire request to the subsequent IP address listening?

Lets say for example someone is requesting something like:

/getUser/6579b440ccc076a4b4685934

I would have an endpoint like:

{
    "name" : "getUser",
    "active" : true,
    "proxy" : {
        "listen_path" : "/getUser/*",
        "upstreams" : {
            "balancing": "roundrobin",
            "targets": [
                {"target": "http://my-ip-address:8080/getUser"}
            ]
        },
        "methods" : ["GET"]
    }
}

And I could somehow pickup userId "6579b440ccc076a4b4685934" in my handler and feed them their user account data?

I basically had never researched API Gateways before and your repo was the first hit. I love the idea of all the grunt work of API architecture done by an open source repo vs. just building it yourself so you can focus on the actual implementation of your custom API rather than all the other issues with scaling, authenticating and rate limiting and other problems this repo seems to solve. There just doesnt seem to be much information on how to wire up real world examples of handlers that are doing anything but feeding static JSON to end users. That doesnt seem very practical. Let me know what I am missing in the docs somewhere where you show a more practical example other than static JSON data

Maybe I missed something in the documentation somewhere where there are examples of real endpoints fetching info from the request and doing backend logic to flush out a response to the user.