turbosonic / api-gateway Goto Github PK
View Code? Open in Web Editor NEWAPI Gateway written in Go
License: GNU General Public License v3.0
API Gateway written in Go
License: GNU General Public License v3.0
so you can have /web/v2
and /mobile/v1
etc, running simultaneously
Dynamic parts of URLs (like IDs) need to be handled and sent to destination services
To monitor usage, find errors, and to show off how fast your API is
Check over the code, add comments, tidy up parts
collate multiple internal requests in to one external request, improving latency for devices with shoddy internet connections
Stop forwarding requests if the underlying service has been broken for sometime
Using APPLICATIONINSIGHTS_INTRUMENTATION_KEY
It checks for roles and scopes which don't exist for open auth
Send the logging output to files
In the config.yaml
given a single endpoint eg. /posts
adding a GET
and a POST
method ends up routing the latter most method to the destination for both. i.e. a GET
request is turned in to a POST
This is bad
No good for POST and PUT ❌
Optional return object if the proxied request fails for any region
Keeping the system alive if something dies
Everything from ?
onwards on the url needs to be sent on to the destination service
This thing needs good testing, no one wants to release a 💩
Expose functionality over a management API
When providing a JWT with no roles property
2018/09/07 03:26:10 http: panic serving 10.244.0.15:49886: interface conversion: interface {} is nil, not string
goroutine 4 [running]:
net/http.(*conn).serve.func1(0x19d0e000)
/home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1697 +0x9f
panic(0x82f55e0, 0x19e40780)
/home/travis/.gimme/versions/go1.9.2.linux.amd64/src/runtime/panic.go:491 +0x1d0
github.com/turbosonic/api-gateway/initializer.checkRoles(0x19d12600, 0x19c60900, 0x3, 0x19c548b0, 0x1, 0x1, 0x19c548d0, 0x1, 0x1, 0x19c60930, ...)
/home/travis/gopath/src/github.com/turbosonic/api-gateway/initializer/initializer.go:120 +0x108
github.com/turbosonic/api-gateway/initializer.createEndpoint.func1(0x8496660, 0x19c0a020, 0x19d12600)
/home/travis/gopath/src/github.com/turbosonic/api-gateway/initializer/initializer.go:58 +0x77
net/http.HandlerFunc.ServeHTTP(0x19c6e280, 0x8496660, 0x19c0a020, 0x19d12600)
/home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1918 +0x34
goji%2eio.dispatch.ServeHTTP(0x8496660, 0x19c0a020, 0x19d12600)
/home/travis/gopath/src/goji.io/dispatch.go:17 +0x91
goji%2eio.(*dispatch).ServeHTTP(0x84e1fec, 0x8496660, 0x19c0a020, 0x19d12600)
<autogenerated>:1 +0x40
github.com/turbosonic/api-gateway/authentication/clients/auth0.CheckJwt.func1(0x8496660, 0x19c0a020, 0x19d12180)
/home/travis/gopath/src/github.com/turbosonic/api-gateway/authentication/clients/auth0/auth0.go:58 +0x426
net/http.HandlerFunc.ServeHTTP(0x19cb9410, 0x8496660, 0x19c0a020, 0x19d12180)
/home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1918 +0x34
github.com/turbosonic/api-gateway/logging.LogHandler.LogHandlerFunc.func1(0x84967c0, 0x19d18000, 0x19d12180)
/home/travis/gopath/src/github.com/turbosonic/api-gateway/logging/logging.go:61 +0xa2
net/http.HandlerFunc.ServeHTTP(0x19c59200, 0x84967c0, 0x19d18000, 0x19d12180)
/home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1918 +0x34
github.com/turbosonic/api-gateway/responseMarshal.AddHeaders.func1(0x84967c0, 0x19d18000, 0x19d12180)
/home/travis/gopath/src/github.com/turbosonic/api-gateway/responseMarshal/responseMarshal.go:23 +0x20f
net/http.HandlerFunc.ServeHTTP(0x19cb9420, 0x84967c0, 0x19d18000, 0x19d12180)
/home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1918 +0x34
github.com/turbosonic/api-gateway/responseMarshal.CorsHandler.func1(0x84967c0, 0x19d18000, 0x19d12180)
/home/travis/gopath/src/github.com/turbosonic/api-gateway/responseMarshal/responseMarshal.go:47 +0x190
net/http.HandlerFunc.ServeHTTP(0x19cb9430, 0x84967c0, 0x19d18000, 0x19d12180)
/home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1918 +0x34
goji%2eio.(*Mux).ServeHTTP(0x19cd1440, 0x84967c0, 0x19d18000, 0x19d12000)
/home/travis/gopath/src/goji.io/mux.go:74 +0x108
net/http.serverHandler.ServeHTTP(0x19c92300, 0x84967c0, 0x19d18000, 0x19d12000)
/home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2619 +0x8e
net/http.(*conn).serve(0x19d0e000, 0x8496f00, 0x19c460a0)
/home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:1801 +0x5d1
created by net/http.(*Server).Serve
/home/travis/.gimme/versions/go1.9.2.linux.amd64/src/net/http/server.go:2720 +0x1f6```
Logging is really to Elasticsearch not ELK, so update to that. Also include the date in the index of the log to allow easier administration of logs and allow for custom index names in ENV files
For all that Grafana glory
Create a Grafana dashboard JSON
Need to add scopes and rules to endpoints via configuration
When setting up a destination that doesn't resolve, the response is an empty 200
Something like this:
alpha
docker imagesbeta
to a commit on master triggers new beta
docker imagesrelease
to a commit on master triggers new latest
docker imagesA config might want to be changed without redeploying the code, this might require a management API to be created on a different port
Things need to be secure, allow for adding SSL certs
It would be pretty useless if a gateway didn't keep out the bad guys
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.