~bigbes/core-go

12996e4a18937dc3938bc093456c9b1453883a56 — Simon Ser 5 years ago 52d6dc9
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
1 files changed, 5 insertions(+), 2 deletions(-)

M client/graphql.go
M client/graphql.go => client/graphql.go +5 -2
@@ 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))
	}