mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-10-12 05:32:36 +00:00
Read only endpoint support (#10)
* This change introduces ability to set additional endpoint leading to the instance of the graphql server connected to the read only database. If regular query is detected and endpoint for `HOST_GRAPHQL_READONLY` value is set, the query will be proxied to it. Mutations and non-graphql will be sent to the `HOST_GRAPHQL` endpoint.
This commit is contained in:
@@ -28,7 +28,7 @@ func createFasthttpClient(timeout int) *fasthttp.Client {
|
||||
}
|
||||
}
|
||||
|
||||
func proxyTheRequest(c *fiber.Ctx) error {
|
||||
func proxyTheRequest(c *fiber.Ctx, currentEndpoint string) error {
|
||||
if !checkAllowedURLs(c) {
|
||||
cfg.Logger.Error("Request blocked", map[string]interface{}{"path": c.Path()})
|
||||
if ifNotInTest() {
|
||||
@@ -46,7 +46,7 @@ func proxyTheRequest(c *fiber.Ctx) error {
|
||||
|
||||
err := retry.Do(
|
||||
func() error {
|
||||
errInt := proxy.DoRedirects(c, cfg.Server.HostGraphQL+c.Path(), 3, cfg.Client.FastProxyClient)
|
||||
errInt := proxy.DoRedirects(c, currentEndpoint+c.Path(), 3, cfg.Client.FastProxyClient)
|
||||
if errInt != nil {
|
||||
cfg.Logger.Error("Can't proxy the request", map[string]interface{}{"error": errInt.Error()})
|
||||
if ifNotInTest() {
|
||||
|
||||
Reference in New Issue
Block a user