|
4 | 4 | <title><![CDATA[Nyami's Blog]]></title>
|
5 | 5 | <link href="http://www.nyami.uk/atom.xml" rel="self"/>
|
6 | 6 | <link href="http://www.nyami.uk/"/>
|
7 |
| - <updated>2017-11-30T22:07:12+00:00</updated> |
| 7 | + <updated>2018-02-09T17:08:48+00:00</updated> |
8 | 8 | <id>http://www.nyami.uk/</id>
|
9 | 9 | <author>
|
10 | 10 | <name><![CDATA[Douglas Cameron]]></name>
|
|
13 | 13 | <generator uri="http://octopress.org/">Octopress</generator>
|
14 | 14 |
|
15 | 15 |
|
| 16 | + <entry> |
| 17 | + <title type="html"><![CDATA[Simple Ping Middleware]]></title> |
| 18 | + <link href="http://www.nyami.uk/blog/2018/02/09/simple-ping-middleware/"/> |
| 19 | + <updated>2018-02-09T16:18:39+00:00</updated> |
| 20 | + <id>http://www.nyami.uk/blog/2018/02/09/simple-ping-middleware</id> |
| 21 | + <content type="html"><![CDATA[<p>If you find yourself needing to create a simple ping endpoint often used by load balancers as a quick check to see if traffic can be directed to your site, rather than complicating the simple and creating an MVC controller etc consider simple middleware.</p> |
| 22 | +
|
| 23 | +<!--more--> |
| 24 | +
|
| 25 | +
|
| 26 | +<p>The ASP.NET Core request pipeline consists of a sequence of request delegates, these delegates are configured using <a href="https://docs.microsoft.com/en-us/dotnet/api/Microsoft.AspNetCore.Builder.RunExtensions?view=aspnetcore-2.0">Run</a>, <a href="https://docs.microsoft.com/en-us/dotnet/api/Microsoft.AspNetCore.Builder.MapExtensions?view=aspnetcore-2.0">Map</a> and <a href="https://docs.microsoft.com/en-us/dotnet/api/Microsoft.AspNetCore.Builder.UseExtensions?view=aspnetcore-2.0">Use</a>, and for our simple ping endpoint Map is a perfect fit. Map will create a branch in the pipeline allowing you to break out of the normal flow which could have the advantage as it can keep this as lightweight as you need. The following can be used to return a 200 response to indicate our site should be good to go, if you need to add some health checks or additional logic you could create more complex middleware.</p> |
| 27 | +
|
| 28 | +<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> |
| 29 | +<span class='line-number'>2</span> |
| 30 | +</pre></td><td class='code'><pre><code class=''><span class='line'>app.Map("/ping", |
| 31 | +</span><span class='line'> ping => ping.Run(async conext => await conext.Response.WriteAsync("ok")));</span></code></pre></td></tr></table></div></figure> |
| 32 | +
|
| 33 | +
|
| 34 | +<p>For more information on Middleware check out <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?tabs=aspnetcore2x#writing-middleware">ASP.NET Core Middleware</a></p> |
| 35 | +]]></content> |
| 36 | + </entry> |
| 37 | + |
16 | 38 | <entry>
|
17 | 39 | <title type="html"><![CDATA[Creating a Self-Signed Certificate for Identity Provider]]></title>
|
18 | 40 | <link href="http://www.nyami.uk/blog/2017/11/18/creating-a-self-signed-certificate-for-identity-provider/"/>
|
|
0 commit comments