MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / GetRequest

Method GetRequest

docs/test-csharp-snippets/Module.cs:82–96  ·  view source on GitHub ↗

=== Snippet 5: HTTP Requests - Get ===

(ProcedureContext ctx)

Source from the content-addressed store, hash-verified

80
81 // === Snippet 5: HTTP Requests - Get ===
82 [SpacetimeDB.Procedure]
83 public static void GetRequest(ProcedureContext ctx)
84 {
85 var result = ctx.Http.Get("https://example.invalid");
86 switch (result)
87 {
88 case Result<HttpResponse, HttpError>.OkR(var response):
89 var body = response.Body.ToStringUtf8Lossy();
90 Log.Info($"Got response with status {response.StatusCode} and body {body}");
91 break;
92 case Result<HttpResponse, HttpError>.ErrR(var e):
93 Log.Error($"Request failed: {e.Message}");
94 break;
95 }
96 }
97
98 // === Snippet 6: HTTP Requests - Send ===
99 [SpacetimeDB.Procedure]

Callers

nothing calls this directly

Calls 4

ToStringUtf8LossyMethod · 0.80
GetMethod · 0.45
InfoMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected