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
HTTP.Body.Enctype is already detected and saved, allowing us to simplify parsing the body content. The method HTTP.Body.Parse<T>() will use this detected enctype to automatically parse the content. HTTP.Body.OnParse(HTTP.Enctype enctype, bool replaceOnMatch, Func<Type, object>) Used to set parser configuration.
Key Points:
HTTP.Body.Enctype: Detected and saved separately.
HTTP.Body.Parse<T>(): Uses the saved enctype to parse content based on the type (e.g., JSON, form data).
Benefits:
Simplicity: One method to handle different enctype values.
Extensible: Easily add support for more enctype values.
Clean Parsing: Logic stays organized by using the already-detected enctype.
Extra: replaceOnMatch Make custom middleware rewrite/override Already set parser handler
varserver=newHTTP.Server();server.Middleware.Add((request,response,next)=>{vartext=request.Body.Text;// .NET 6+, also can use Json.NET (Newtonsoft Json) or others implementation// Adding JSON Enctype parserrequest.Body.OnParse(HTTP.Enctype.Json,false,(type)=>JsonSerializer.Deserialize(text,type,JsonSerializerOptions.Default));// Adding YAML Enctype parserrequest.Body.OnParse(HTTP.Enctype.Yml,false,(type)=>Example.Method(text,type,ExampleOptions.Default));// Adding XML Enctype parserrequest.Body.OnParse(HTTP.Enctype.Xml,false,(type)=>Example.Method(text,type,ExampleOptions.Default));
...next();});server.To.Open(newUri("https://127.0.0.1:8080"));
The text was updated successfully, but these errors were encountered:
I @ale1o@AlecioFuranze (Alecio Furanze)
Currently, there are no built-in parsers for Enctype, but the mechanism to implement middleware for parsing is already in place. In future versions, we will add built-in parsers for Enctypes such as JSON, XML, and YAML. This will reduce the need to manually create Enctype parsers to process the request body. However, even after the addition of these integrated parsers, you can still choose to use a more sophisticated parser, and the library will continue to support these parsing options via middleware in case you need to parse unsupported Enctypes or for any other reason. The key difference is that the built-in parsers will be available by default.
Enctype
Status
🌐 UrlEncoded
⏳ Planned
📂 Multipart
⏳ Planned
📄 Json
⏳ Planned
📜 Yaml
⏳ Planned
🗂️ Xml
⏳ Planned
📊 Csv
⏳ Planned
⚛️ GraphQL
⏳ Planned
📦 SoapXml
⏳ Planned
📁 MultipartRelated
⏳ Planned
Notes:
⏳ Planned: This Enctype is scheduled to be added in future versions with parsing support.
✅ Built-in: This Enctype already has built-in parsing support in the library.
Description:
HTTP.Body.Enctype
is already detected and saved, allowing us to simplify parsing the body content. The methodHTTP.Body.Parse<T>()
will use this detectedenctype
to automatically parse the content.HTTP.Body.OnParse(HTTP.Enctype enctype, bool replaceOnMatch, Func<Type, object>)
Used to set parser configuration.Key Points:
HTTP.Body.Enctype
: Detected and saved separately.HTTP.Body.Parse<T>()
: Uses the savedenctype
to parse content based on the type (e.g., JSON, form data).Benefits:
enctype
values.enctype
values.enctype
.replaceOnMatch
Make custom middleware rewrite/override Already set parser handlerExample Usage:
Usage middleware to parse HTTP.Body
The text was updated successfully, but these errors were encountered: