4 ms·
Virtualizing APIs with Go and Python
- deleted 11y ago[deleted]
- nly 11y agoIsn't this just CGI, straight out of the 90s, but with a needless cycle through JSON?
- deforciant 11y agoapparently middleware (cgi) is just an additional feature here
- sdegutis 11y agoCorrect.
- 5h 11y agoThat's kind of what i was thinking - somewhere between good ol' cgi and a reverse proxy .... Unfortunate because I'm semi-looking for a simple service that will let me configure a stateful new frontend to an old API - title made me think it might be along those lines.
- rakoo 11y agoThere's a huge difference: CGI is the ultimate backend in the HTTP stack, while this allows you to run scripts as middleware (ie modifying the response headers/body based on previous processing)
- bmurphy1976 11y agoNot necessarily true. CGI could shell out to other CGI code if it wanted to. Turtles all the way down.
- rakoo 11y agoWhat if the backend is not CGI ? What if I want to use a script to gzip the output of a backend that doesn't compress anything ? Of course you can just call that backend through HTTP, but then you add another huge dependency on your little script that should just be as simple as "gzip -c -"
- Lobster101 11y agoIt is similar, but one advantage is that you can run your existing CGI scripts (C/C++/perl/ ...) without a remote web server. That interests me as it would allow re-use of some existing scripts and it would also allow me to wrap some legacy interfaces.
- _RPM 11y ago`data = sys.stdin.readlines()` in their Python script. Is it common to not check return values of functions in Python land? I might be too disciplined coming from a C background, but what if getting the data fails?
- detaro 11y agoThen the function throws an exception and the program terminates, since there isn't anything useful it can do about the situation. What would you suggest it to do if it can't read from stdin?
- skywhopper 11y agoI don't think "virtualization" is quite the right word. "Middleware" is better. "Protocol rewriting" might be more honest. Though in my day we just called this a "hack". It's certainly nothing new, whether you do it with a CGI script a fancy rewrite module on your reverse proxy or a network "appliance" endpoint like a BIG-IP. It's definitely something every good ops or devops person should be able to pull off to fix those unfixable problems that crop up from vendor intransigence or developer pushback.
- boomlinde 11y agoreadlines() just to pick the first seems weird if you expect a single line. I'd read the whole thing in one go with read(). Then I start wondering if it wouldn't make more sense to keep the stream open and just iterate over new messages line by line and avoid the overhead of loading an executable, importing libraries etc. on every request
- mring33621 11y agoSo...AOP for web calls.
- jaytaylor 11y agoDirect link to Hoverfly source code: https://github.com/SpectoLabs/hoverfly https://github.com/SpectoLabs/hoverfly
- carlisle_ 11y agoWhy is there image and whitespace that takes up >50% of the width of the page? It makes it so obnoxious to read.
- tjcunliffe 11y agoPoint taken. Will sort it.