From 12996e4a18937dc3938bc093456c9b1453883a56 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 30 Nov 2020 11:24:42 +0000 Subject: [PATCH] client: add config option to override API origin If the config file contains an "api-origin" key for a service, prefer it instead of "origin". This allows users to directly point the Python frontend to the Go backend for local development, without having to setup a reverse proxy. This is the Go port of [1]. While at it, use GetOrigin for symmetry with the Python code. [1]: https://git.sr.ht/~sircmpwn/meta.sr.ht/commit/6c2ee03923fe65423a2c55e6648f555c08db827a --- client/graphql.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/graphql.go b/client/graphql.go index 0f0de576717e4f0c415c034c02cd017a16430dd5..f4f47388951138413d633230cabee76e4252271c 100644 --- a/client/graphql.go +++ b/client/graphql.go @@ -31,8 +31,11 @@ func Execute(ctx context.Context, username string, svc string, } conf := config.ForContext(ctx) - origin, ok := conf.Get(svc, "origin") - if !ok { + origin, _ := conf.Get(svc, "api-origin") + if origin == "" { + origin = config.GetOrigin(conf, svc, false) + } + if origin == "" { panic(fmt.Errorf("No %s origin specified in config.ini", svc)) }