You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AustinHarris.JsonRpc.AspNetCore/AustinHarris.JsonRpc.AspNetCore.csproj
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@
6
6
<Product>Json-Rpc.Net ASP.NET Core host</Product>
7
7
<Description>ASP.NET Core / Kestrel hosting for JSON-RPC.Net: MapJsonRpc endpoint (PipeReader in, BodyWriter out, no strings), a raw Kestrel ConnectionHandler for JSON-RPC over TCP, and DI registration of services.</Description>
`MapJsonRpc` adds no authorization, TLS requirement, rate limit or request deadline by itself; apply those
62
62
policies explicitly. `MaxRequestBytes` limits the HTTP body, but there is no batch-count or response-size limit.
63
-
Keep `Config.IncludeExceptionDetails` off for untrusted clients; the default still sends an unhandled exception's
64
-
CLR type name and message, see [Exception disclosure](https://github.com/Astn/JSON-RPC.NET#exception-disclosure)
63
+
Keep `Config.IncludeExceptionDetails` off for untrusted clients: by default an unhandled exception is answered as
64
+
`-32603` with `data: null`, see [Exception disclosure](https://github.com/Astn/JSON-RPC.NET#exception-disclosure)
65
65
in the main README.
66
66
67
67
`MapJsonRpc(pattern = "/jsonrpc", options = null)` uses the options from `AddJsonRpc` unless you pass your own,
@@ -87,9 +87,10 @@ per-request data from the context instead.
87
87
declares a `[JsonRpcMethod]`. Private methods count, so the attribute is the whole access list, and an MVC
88
88
controller that carries it becomes a singleton too.
89
89
90
-
A class deriving from `JsonRpcService` binds itself to the default session in its constructor. Registering it here
91
-
as well is harmless when the effective session is the default. With `SessionId` set, the host binds it to that
92
-
session in addition, so it stays reachable on the default session too.
90
+
The host binds every registered service to its effective session: the session given to `AddJsonRpcService`, else
91
+
`JsonRpcOptions.SessionId`, else the default. A class deriving from `JsonRpcService` also binds itself to the
92
+
default session in its parameterless constructor, so with `SessionId` set it is reachable in both; write
93
+
`: base(false)` in the subclass to leave that to the host.
93
94
94
95
## Raw connection (TCP, Unix socket, named pipe)
95
96
@@ -136,7 +137,7 @@ in the main README.
136
137
|---|---|---|---|
137
138
|`EnableAsyncMethods`| false | HTTP and raw | use `ProcessAsync` for `Task`/`ValueTask` methods, with host cancellation |
138
139
|`SessionId`| default session | HTTP and raw | which session's methods answer |
139
-
|`SessionSelector`| null | HTTP | pick the session per request from the `HttpContext`; it must map to a fixed set of ids, because an unknown id creates a session that persists|
140
+
|`SessionSelector`| null | HTTP | pick the session per request from the `HttpContext`; an id that was never registered answers `-32601` and creates nothing|
140
141
|`Serializer`| session, then `Config.Serializer`| HTTP and raw | serializer for this host |
141
142
|`ContextFactory`|`HttpContext`| HTTP | what `JsonRpcContext.Current()` returns |
142
143
|`MaxRequestBytes`| 4 MB | HTTP body, or one raw document | larger bodies get 413; a larger raw document aborts the connection |
<Description>Json.NET (Newtonsoft.Json) serializer for JSON-RPC.Net. Lenient parsing and full Json.NET conversion semantics; pass JsonSerializerSettings to control it.</Description>
<Description>System.Text.Json serializer for JSON-RPC.Net. Utf8JsonReader/Utf8JsonWriter end to end; pass JsonSerializerOptions to control it.</Description>
Copy file name to clipboardExpand all lines: AustinHarris.JsonRpcTestN/AspNetCoreTests.cs
+41-1Lines changed: 41 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -194,7 +194,7 @@ public async Task Tcp_DocumentSplitAcrossWrites_IsReassembled()
194
194
195
195
// ------------------------------------------------------------------ DI binding honours JsonRpcOptions.SessionId
196
196
197
-
/// <summary>A JsonRpcService subclass built by DI: its base constructor binds it to the default session.</summary>
197
+
/// <summary>A JsonRpcService subclass built by DI: its base constructor binds it to the default session, and the host binds it to the configured one as well.</summary>
198
198
publicclassTenantAutoService:JsonRpcService
199
199
{
200
200
[JsonRpcMethod("tenant.ping")]
@@ -251,6 +251,46 @@ public async Task Http_JsonRpcServiceSubclass_IsBoundToTheConfiguredSession()
251
251
}
252
252
}
253
253
254
+
/// <summary>A JsonRpcService subclass that does not bind itself: the host is its only binder.</summary>
Assert.AreEqual("System.ArgumentException",(string)data["ClassName"],"a wrapped exception is reported through its inner exception (unchanged legacy behaviour)");
0 commit comments