From b8fe8f6ed2a9e46a4ded4bb15e79c6514ea5bb1c Mon Sep 17 00:00:00 2001 From: TymKh Date: Fri, 3 Oct 2025 17:20:16 +0200 Subject: [PATCH] extract url into the context in jsonrpcserver --- rpcserver/jsonrpc_server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rpcserver/jsonrpc_server.go b/rpcserver/jsonrpc_server.go index d8799d5..a96ed59 100644 --- a/rpcserver/jsonrpc_server.go +++ b/rpcserver/jsonrpc_server.go @@ -12,6 +12,7 @@ import ( "io" "log/slog" "net/http" + "net/url" "strconv" "strings" "time" @@ -52,6 +53,7 @@ type ( highPriorityKey struct{} builderNetSentAtKey struct{} signerKey struct{} + urlKey struct{} originKey struct{} sizeKey struct{} ) @@ -267,6 +269,8 @@ func (h *JSONRPCHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } ctx = context.WithValue(ctx, signerKey{}, signer) } + // r.URL + ctx = context.WithValue(ctx, urlKey{}, r.URL) // read request var req jsonRPCRequest @@ -417,3 +421,7 @@ func GetOrigin(ctx context.Context) string { func GetRequestSize(ctx context.Context) int { return ctx.Value(sizeKey{}).(int) } + +func GetURL(ctx context.Context) *url.URL { + return ctx.Value(urlKey{}).(*url.URL) +}