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: README.md
+63-9Lines changed: 63 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,8 @@ The old NuGet package has been unlisted and will not receive any updates any mor
51
51
-[text](#text)
52
52
-[json](#json)
53
53
-[xml](#xml)
54
+
-[negotiate](#negotiate)
55
+
-[negotiateWith](#negotiatewith)
54
56
-[htmlFile](#htmlfile)
55
57
-[dotLiquid](#dotliquid)
56
58
-[dotLiquidTemplate](#dotliquidtemplate)
@@ -481,7 +483,7 @@ let app =
481
483
482
484
### setBody
483
485
484
-
`setBody` sets or modifies the body of the `HttpResponse`. This http handler triggers the response being sent to the client and other http handlers afterwards will not be able to modify the HTTP headers anymore.
486
+
`setBody` sets or modifies the body of the `HttpResponse`. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.
485
487
486
488
#### Example:
487
489
@@ -494,7 +496,7 @@ let app =
494
496
495
497
### setBodyAsString
496
498
497
-
`setBodyAsString` sets or modifies the body of the `HttpResponse`. This http handler triggers the response being sent to the client and other http handlers afterwards will not be able to modify the HTTP headers anymore.
499
+
`setBodyAsString` sets or modifies the body of the `HttpResponse`. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.
498
500
499
501
#### Example:
500
502
@@ -507,7 +509,7 @@ let app =
507
509
508
510
### text
509
511
510
-
`text` sets or modifies the body of the `HttpResponse`. This http handler triggers the response being sent to the client and other http handlers afterwards will not be able to modify the HTTP headers anymore.
512
+
`text` sets or modifies the body of the `HttpResponse` by sending a plain text value to the client.. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.
511
513
512
514
The different between `text` and `setBodyAsString` is that this http handler also sets the `Content-Type` HTTP header to `text/plain`.
513
515
@@ -522,7 +524,7 @@ let app =
522
524
523
525
### json
524
526
525
-
`json` sets or modifies the body of the `HttpResponse`. This http handler triggers the response being sent to the client and other http handlers afterwards will not be able to modify the HTTP headers anymore. It also sets the `Content-Type` HTTP header to `application/json`.
527
+
`json` sets or modifies the body of the `HttpResponse` by sending a JSON serialized object to the client. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more. It also sets the `Content-Type` HTTP header to `application/json`.
526
528
527
529
#### Example:
528
530
@@ -541,7 +543,7 @@ let app =
541
543
542
544
### xml
543
545
544
-
`xml` sets or modifies the body of the `HttpResponse`. This http handler triggers the response being sent to the client and other http handlers afterwards will not be able to modify the HTTP headers anymore. It also sets the `Content-Type` HTTP header to `application/xml`.
546
+
`xml` sets or modifies the body of the `HttpResponse` by sending an XML serialized object to the client. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more. It also sets the `Content-Type` HTTP header to `application/xml`.
545
547
546
548
#### Example:
547
549
@@ -559,9 +561,61 @@ let app =
559
561
]
560
562
```
561
563
564
+
### negotiate
565
+
566
+
`negotiate` sets or modifies the body of the `HttpResponse` by inspecting the `Accept` header of the HTTP request and deciding if the response should be sent in JSON or XML. If the client is indifferent then the default response will be sent in JSON.
567
+
568
+
This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.
`negotiateWith` sets or modifies the body of the `HttpResponse` by inspecting the `Accept` header of the HTTP request and deciding in what mimeType the response should be sent. A dictionary of type `IDictionary<string, obj -> HttpHandler>` is used to determine which `obj -> HttpHandler` function should be used to convert an object into a `HttpHandler` for a given mime type.
589
+
590
+
This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.
591
+
592
+
#### Example:
593
+
594
+
```fsharp
595
+
[<CLIMutable>]
596
+
type Person =
597
+
{
598
+
FirstName : string
599
+
LastName : string
600
+
}
601
+
602
+
// xml and json are the two HttpHandler functions from above
`htmlFile` sets or modifies the body of the `HttpResponse` with the contents of a physical html file. This http handler triggers the response being sent to the client and other http handlers afterwards will not be able to modify the HTTP headers anymore.
618
+
`htmlFile` sets or modifies the body of the `HttpResponse` with the contents of a physical html file. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.
565
619
566
620
This http handler takes a relative path of a html file as input parameter and sets the HTTP header `Content-Type` to `text/html`.
567
621
@@ -576,7 +630,7 @@ let app =
576
630
577
631
### dotLiquid
578
632
579
-
`dotLiquid` uses the [DotLiquid](http://dotliquidmarkup.org/) template engine to set or modify the body of the `HttpResponse`. This http handler triggers the response being sent to the client and other http handlers afterwards will not be able to modify the HTTP headers anymore.
633
+
`dotLiquid` uses the [DotLiquid](http://dotliquidmarkup.org/) template engine to set or modify the body of the `HttpResponse`. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.
580
634
581
635
The `dotLiquid` handler requires the content type and the actual template to be passed in as two string values together with an object model. This handler is supposed to be used as the base handler for other http handlers which want to utilize the DotLiquid template engine (e.g. you could create an SVG handler on top of it).
582
636
@@ -599,7 +653,7 @@ let app =
599
653
600
654
### dotLiquidTemplate
601
655
602
-
`dotLiquidTemplate` uses the [DotLiquid](http://dotliquidmarkup.org/) template engine to set or modify the body of the `HttpResponse`. This http handler triggers the response being sent to the client and other http handlers afterwards will not be able to modify the HTTP headers anymore.
656
+
`dotLiquidTemplate` uses the [DotLiquid](http://dotliquidmarkup.org/) template engine to set or modify the body of the `HttpResponse`. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.
603
657
604
658
This http handler takes a relative path of a template file, an associated model and the contentType of the response as parameters.
605
659
@@ -639,7 +693,7 @@ let app =
639
693
640
694
### razorView
641
695
642
-
`razorView` uses the official ASP.NET Core MVC Razor view engine to compile a page and set the body of the `HttpResponse`. This http handler triggers the response being sent to the client and other http handlers afterwards will not be able to modify the HTTP headers anymore.
696
+
`razorView` uses the official ASP.NET Core MVC Razor view engine to compile a page and set the body of the `HttpResponse`. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.
643
697
644
698
The `razorView` handler requires the view name, an object model and the contentType of the response to be passed in. It also requires to be enabled through the `AddRazorEngine` function during start-up.
0 commit comments