go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

I need a ServerHTTP, But not in Serverless.

Open litecy opened this issue 1 month ago • 2 comments

In our business, we need to apply overall encryption and routing wrapping to certain domains and endpoints. The actual backend uses the same set of APIs, and it should also work in non-encrypted mode. For example: APIs: a, b, c, d Main business domain: X Encrypted business domains: Y, Z

In normal mode, the following are accessible: X/*, Y/a, Y/b, Z/a, Z/b

The endpoints that require encrypted access are: Y/c, Y/d, Z/c, Z/d

Before go-zero version 1.8, we registered an additional encrypted route n, attached a middleware m to n, and in m we decrypted the request, rebuild the aim request, then called Server.ServerHTTP, and finally re-encrypted the response.

After version 1.8, ServerHTTP was removed. I tried using Serverless, but Serverless and the normal mode cannot coexist.

Would it be possible to add a wrapper that supports ServerHTTP, or add an initialization method in Serverless that does not call build?

litecy avatar Nov 18 '25 01:11 litecy

add an initialization method in Serverless that does not call build

When to call build?

kevwan avatar Nov 19 '25 14:11 kevwan

it seems not a good idea. Instead add a implement like rest.ServerRaw to have ServerHTTP act as a wrap of rest.Server?

litecy avatar Nov 19 '25 15:11 litecy