SimpleREST.NET 0.1
A simple and minimal api framework for .net base on Express.js
Loading...
Searching...
No Matches
SimpleRest.Api.SimpleRestBody Class Reference

The body of a SimpleRest.Api.SimpleRestRequest. This class encapsulates the content of an HTTP request body, providing access to both raw byte data and deserialized content. More...

Public Member Functions

 SimpleRestBody (string contents, JsonSerializerOptions jsonOptions)
 
 SimpleRestBody (HttpListenerRequest request, JsonSerializerOptions jsonOptions)
 Initializes a new instance of the SimpleRestBody class using the specified HttpListenerRequest.
 
T? As< T > ()
 The function As<T> returns the content as type T if T is a reference type.
 
TBody? GetContent< TBody > ()
 The function GetContent<TBody> deserializes the Content property into an object of type TBody .
 

Properties

string Content [get]
 Gets the content of the request body as a UTF-8 encoded string.
 
byte[] Bytes [get]
 Gets the raw content of the request body as a byte array.
 

Detailed Description

The body of a SimpleRest.Api.SimpleRestRequest. This class encapsulates the content of an HTTP request body, providing access to both raw byte data and deserialized content.

Definition at line 128 of file SimpleRestRequest.cs.

Constructor & Destructor Documentation

◆ SimpleRestBody() [1/2]

SimpleRest.Api.SimpleRestBody.SimpleRestBody ( string contents,
JsonSerializerOptions jsonOptions )

Definition at line 131 of file SimpleRestRequest.cs.

◆ SimpleRestBody() [2/2]

SimpleRest.Api.SimpleRestBody.SimpleRestBody ( HttpListenerRequest request,
JsonSerializerOptions jsonOptions )

Initializes a new instance of the SimpleRestBody class using the specified HttpListenerRequest.

Parameters
requestThe HttpListenerRequest from which to read the body content.

Definition at line 142 of file SimpleRestRequest.cs.

Member Function Documentation

◆ As< T >()

T? SimpleRest.Api.SimpleRestBody.As< T > ( )

The function As<T> returns the content as type T if T is a reference type.

Template Parameters
TThe type to which the content should be deserialized.
Returns
An instance of type T , or null if the conversion fails.

Definition at line 171 of file SimpleRestRequest.cs.

◆ GetContent< TBody >()

TBody? SimpleRest.Api.SimpleRestBody.GetContent< TBody > ( )

The function GetContent<TBody> deserializes the Content property into an object of type TBody .

Template Parameters
TBodyThe type to which the content should be deserialized.
Returns
An instance of type TBody , or null if the deserialization fails.

Definition at line 184 of file SimpleRestRequest.cs.

Property Documentation

◆ Bytes

byte [] SimpleRest.Api.SimpleRestBody.Bytes
get

Gets the raw content of the request body as a byte array.

Definition at line 162 of file SimpleRestRequest.cs.

◆ Content

string SimpleRest.Api.SimpleRestBody.Content
get

Gets the content of the request body as a UTF-8 encoded string.

Definition at line 157 of file SimpleRestRequest.cs.


The documentation for this class was generated from the following file: