The registerHttp function is not available in TypeScript runtime

For implementing a third-party integration that will call our Nakama instance for payment validation, we need the ability to send custom HTTP response codes (e.g., 204) and headers. However, RPCs do not currently support setting custom HTTP response codes or headers.

We noticed that the recently introduced registerHttp function could potentially solve this issue, but it doesn’t appear to be available in the TypeScript runtime yet.

Is it possible to make the registerHttp function available in TypeScript, or is there another way to gain control over HTTP response codes and headers?

Also on GitHub: The `registerHttp` function is not available in TypeScript runtime · Issue #1319 · heroiclabs/nakama · GitHub

Hello @RobinM,

The lack of JS support for registerHttp is by design, bridging the full request/response flow between Go and JS has many implications which wouldn’t render it effective, even if possible.

My advise here would be to implement this API using the Go runtime. You can still use JS runtime for your existing codebase, as their use can be mixed.

Also be mindful that registerHttp bypasses any standard RPC Nakama auth validation, so you’d need to implement your own.

Best.

Hi @sesposito,

Thanks for the quick reply. Most of our code which needs to process this request is in TypeScript. Is there any other way to call TypeScript code from Go other then calling a localhost RPC via HTTP? Otherwise I’ll go for the following setup, which is not ideal, but I think should work;

  • Go Runtime will register a HTTP endpoint with registerHttp, validate it and does some authentication.
  • Go Runtime calls a TypeScript RPC via HTTP
  • TypeScript RPC processes the request with the existing TypeScript code

Thanks!

What you suggest should work and is the only option to call JS code from the Go runtime.

1 Like