PageRenderTime 56ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/index.html

https://gitlab.com/StachuDotNet/NancyFx-Talk
HTML | 480 lines | 388 code | 88 blank | 4 comment | 0 complexity | 05c218eef617556d1fa2ceafd3cd4a8d MD5 | raw file
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>NancyFX for a Simpler Web</title>
  6. <meta name="description" content="NancyFX for a Simpler Web">
  7. <meta name="author" content="Stachu Korick">
  8. <meta name="apple-mobile-web-app-capable" content="yes" />
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
  11. <link rel="stylesheet" href="css/reveal.css">
  12. <link rel="stylesheet" href="css/serif.css" id="theme">
  13. <!-- Code syntax highlighting -->
  14. <link rel="stylesheet" href="css/zenburn.css">
  15. <!--[if lt IE 9]>
  16. You don't deserve a shiv.
  17. <![endif]-->
  18. <style>
  19. #split-book img {
  20. margin: 0;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. <div class="reveal">
  26. <div class="slides">
  27. <section>
  28. <h2>NancyFx for a Simpler Web</h2>
  29. <h3>Stachu Korick</h3>
  30. </section>
  31. <section>
  32. <section>
  33. <h2>80 Minutes? I'll try.</h2>
  34. </section>
  35. <section id="split-book">
  36. <img class="fragment" src="http://i.imgur.com/I6WQLX3.jpg?1" alt="">
  37. <img class="fragment" src="http://i.imgur.com/BiuoLPJ.jpg?1" alt="">
  38. <img class="fragment" src="http://i.imgur.com/kA9PRck.jpg?1" alt="">
  39. <img class="fragment" src="http://i.imgur.com/63Jazau.jpg?1" alt="">
  40. <img class="fragment" src="http://i.imgur.com/7Vu1dnb.jpg?1" alt="">
  41. </section>
  42. </section>
  43. <section>
  44. <h2>Who am I?</h2>
  45. <ul>
  46. <li>Not an MVP</li>
  47. <li class="fragment">Growing software developer working at AcademyOne</li>
  48. <li class="fragment">I solve Rubik's Cubes a lot, and write software in that space, using 'weird' tech, like
  49. <ul>
  50. <li>F#</li>
  51. <li>NancyFx</li>
  52. <li>SignalR</li>
  53. <li>Graph/NoSQL databses</li>
  54. <li>DDD, CQRS, Event-Sourcing,e tc.</li>
  55. </ul>
  56. </li>
  57. </ul>
  58. </section>
  59. <section>
  60. <h3>Brief Overview of NancyFx</h3>
  61. <ul>
  62. <li>Open-Source</li>
  63. <li>Based off of Ruby's Sinatra</li>
  64. <li>Lightweight and low-ceremony</li>
  65. <li>Works on .NET and Mono</li>
  66. <li>Has sensible defaults, but lets you easily override</li>
  67. </ul>
  68. </section>
  69. <section>
  70. <h2>How the Internet Works</h2>
  71. <h4>(the responsibilities of a web framework)</h4>
  72. <ul>
  73. <li>Client sends request</li>
  74. <li>Server picks up request</li>
  75. <li>Server handles request</li>
  76. <li>Server prepares response</li>
  77. <li>Server sends back response</li>
  78. <li>Client deals with response</li>
  79. <li>... Repeat!</li>
  80. </ul>
  81. </section>
  82. <section>
  83. <h2>Available Hosts</h2>
  84. <ul>
  85. <li>ASP.NET (IIS)</li>
  86. <li>WCF</li>
  87. <li>OWIN</li>
  88. <li>Self-Hosting</li>
  89. <li>Anything (even mono on a raspberry pi)</li>
  90. </ul>
  91. </section>
  92. <section>
  93. <h2>Modules:</h2>
  94. <h2>The Endpoints of NancyFx</h2>
  95. <pre><code data-trim contenteditable>
  96. public class ResourceModule : NancyModule
  97. {
  98. public ResourceModule() : base("/products")
  99. {
  100. Get["/list"] = parameters => {
  101. return "The list of products";
  102. };
  103. }
  104. }</code></pre>
  105. <p>"Get me to the code!"</p>
  106. </section>
  107. <section>
  108. <section>
  109. <h2>An Explanation of Routing</h2>
  110. </section>
  111. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  112. <h3>METHOD+PATTERN+(CONDITION)+ACTION</h3>
  113. <p><img src="http://i.imgur.com/lKS8zji.png?1" alt="" /></p>
  114. </section>
  115. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  116. <h2>Methods available</h2>
  117. <ul>
  118. <li>GET</li>
  119. <li>POST</li>
  120. <li>PATCH</li>
  121. <li>PUT</li>
  122. <li>DELETE</li>
  123. <li>OPTIONS</li>
  124. <li>HEAD</li>
  125. </ul>
  126. </section>
  127. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  128. <h2>Patterns</h2>
  129. <ul>
  130. <li>Literal strings "/my/route"</li>
  131. <li>Captures "/my/{route}"</li>
  132. <li>Route Constraints "/my/{route:alpha}"</li>
  133. </ul>
  134. <h4>Note! Different patterns have different weight</h4>
  135. <p>(kind of like CSS selectors)</p>
  136. </section>
  137. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  138. <h3>Actions</h3>
  139. <pre><code data-trim contenteditable>
  140. Func&lt;dynamic,dynamic&gt;
  141. </code></pre>
  142. <p>Will determine response type automatically, or you can use the Response object to manually negotiate content</p>
  143. </section>
  144. </section>
  145. <section>
  146. <section>
  147. <h2>Model-Binding</h2>
  148. </section>
  149. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  150. <h3>The model-binder will pick up on</h3>
  151. <ul>
  152. <li>Query strings</li>
  153. <li>Captured parameters</li>
  154. <li>Body of request</li>
  155. </ul>
  156. </section>
  157. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  158. <h3>Available Syntaxes</h3>
  159. <pre><code data-trim contenteditable>
  160. Foo f = this.Bind();
  161. var f = this.Bind&lt;Foo&gt;();
  162. var f = this.BindTo(instance);
  163. </code></pre>
  164. </section>
  165. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  166. <h3>How Does Nancy Figure Out What Data I'm Passing In?</h3>
  167. <p>Nancy will look at your HTTP Content-Type header.</p>
  168. <p>i.e. - application/json will result in being interpreted as JSON</p>
  169. </section>
  170. </section>
  171. <section>
  172. <section>
  173. <h2>The Bootstrapper</h2>
  174. </section>
  175. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  176. <h3>What is the Bootstrapper</h3>
  177. <ul>
  178. <li>The bootstrapper is Nancy's way of letting you change the runtime behaviour of NancyFx</li>
  179. <li>Basically a global.asax and web.config combo that isn't as bad as either</li>
  180. </ul>
  181. </section>
  182. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  183. <h3>Take me to the code!</h3>
  184. <p>Ok.</p>
  185. </section>
  186. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  187. <h3>What if my Bootstrapper's too long?</h3>
  188. <p>IApplicationStartup and IRegistrations to the rescue!</p>
  189. <pre><code data-trim contenteditable>
  190. public class ApplicationStartup : IApplicationStartup
  191. {
  192. public void Initialize(IPipelines pipelines) {/*...*/)}
  193. }</code></pre>
  194. <pre><code data-trim contenteditable>
  195. public class Registrations : IRegistrations
  196. {
  197. public IEnumerable&lt;CollectionTypeRegistration&gt;
  198. CollectionTypeRegistrations { get { /*...*/ } }
  199. public IEnumerable&lt;InstanceRegistration&gt;
  200. InstanceRegistrations { get { /*...*/ } }
  201. public IEnumerable&lt;TypeRegistration&gt;
  202. TypeRegistrations { get { /*...*/ } }
  203. }</code></pre>
  204. </section>
  205. </section>
  206. <section>
  207. <section>
  208. <h2>Hooks?!</h2>
  209. <p>To the code!</p>
  210. </section>
  211. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  212. <h3>What are Hooks good for?</h3>
  213. <ul>
  214. <li>Caching</li>
  215. <li>Security</li>
  216. <li>Rewriting requests/responses</li>
  217. <li>Dealing with runtime errors</li>
  218. </ul>
  219. </section>
  220. </section>
  221. <section>
  222. <section>
  223. <h2>How do I Async?</h2>
  224. </section>
  225. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  226. <h3>Route-Level</h3>
  227. <pre><code data-trim contenteditable>
  228. Get["/", true] = async (x, ct) =>
  229. {
  230. await Task.Delay(1000);
  231. return "done";
  232. };
  233. </code></pre>
  234. </section>
  235. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  236. <h2>Hook-Level</h2>
  237. <pre><code data-trim contenteditable>
  238. Before += async (ctx, ct) =>
  239. {
  240. await Task.Delay(5000);
  241. return null;
  242. };
  243. </code></pre>
  244. </section>
  245. </section>
  246. <section>
  247. <section>
  248. <h2>Views and ViewEngines</h2>
  249. </section>
  250. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  251. <h3>Supported ViewEngines</h3>
  252. <ul>
  253. <li>Raw HTML</li>
  254. <li>SuperSimpleViewEngine</li>
  255. <li>Razor</li>
  256. <li>Spark</li>
  257. <li>NHaml</li>
  258. <li>NDjango</li>
  259. <li>dotLiquid</li>
  260. <li>Parrot</li>
  261. <li>etc.</li>
  262. </ul>
  263. </section>
  264. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  265. <h3>Syntax for Returning a View</h3>
  266. <p>Without a model</p>
  267. <pre><code data-trim contenteditable>
  268. return View["viewName"];
  269. </code></pre>
  270. <p>With a model</p>
  271. <pre><code data-trim contenteditable>
  272. return View["viewName", model];
  273. </code></pre>
  274. </section>
  275. </section>
  276. <section>
  277. <section>
  278. <h2>NancyFx is Highly-Testable</h2>
  279. </section>
  280. <section author="Stachu Korick" description="NancyFx for a Simpler Web" theme="serif" title="NancyFx" transition="default">
  281. <p>For more, <a target="_blank" href="http://www.marcusoft.net/2013/01/NancyTesting1.html">go here</a></p>
  282. </section>
  283. </section>
  284. <section>
  285. <section>
  286. <h2>Why use NancyFx?</h2>
  287. <ul>
  288. <li>Terse syntax; less ceremony</li>
  289. <li>Better extension points</li>
  290. <li>Easier testing</li>
  291. <li>Automatic dependency-injection</li>
  292. <li>Completely customizable</li>
  293. <li>Runs anywhere (even in an .exe!)</li>
  294. <li>No web.config nonsense</li>
  295. <li>Support and community</li>
  296. </ul>
  297. </section>
  298. <section>
  299. <p>
  300. Christian Horsdal, author of <q>Nancy Web Development</q>:
  301. </p>
  302. <blockquote cite="http://searchservervirtualization.techtarget.com/definition/Our-Favorite-Technology-Quotations">
  303. &ldquo;In this seemingly [...] rational realm of technology, we tend to focus a lot on the concrete and measurable things when we choose between one technology and the other...
  304. I think we often miss an important component in these directions, namely the style.&rdquo;
  305. </blockquote>
  306. </section>
  307. </section>
  308. <section>
  309. <h1>Done!</h1>
  310. <p>Time for odds and ends!</p>
  311. </section>
  312. <section>
  313. <h3>What IOC containers can I use?</h3>
  314. <p>Currently available:</p>
  315. <ul>
  316. <li>Windsor</li>
  317. <li>Unity</li>
  318. <li>StructureMap</li>
  319. <li>Ninject</li>
  320. <li>AutoFac</li>
  321. <li>TinyIOC</li>
  322. </ul>
  323. </section>
  324. <section>
  325. <h2>Content-Negotiation</h2>
  326. <pre><code data-trim contenteditable>
  327. Get["/"] = parameters => {
  328. return Negotiate
  329. .WithModel(new RatPack {FirstName = "Nancy "})
  330. .WithMediaRangeModel("text/html",
  331. new RatPack {FirstName = "Nancy fancy pants"})
  332. .WithView("negotiatedview")
  333. .WithHeader("X-Custom", "SomeValue");
  334. };
  335. </code></pre>
  336. </section>
  337. <section>
  338. <h3>What do you want to see?</h3>
  339. <p>NancyFx &amp;</p>
  340. <ul>
  341. <li>F#</li>
  342. <li>Caching</li>
  343. <li>Authentication
  344. <ul>
  345. <li>Basic</li>
  346. <li>Forms</li>
  347. <li>Stateless</li>
  348. </ul>
  349. </li>
  350. <li>Localization</li>
  351. </ul>
  352. <aside class="notes">
  353. This slide has fragments which are also stepped through in the notes window.
  354. </aside>
  355. </section>
  356. <section>
  357. <section id="fragments">
  358. <h2>Fragments</h2>
  359. <p>Hit the next arrow...</p>
  360. <p class="fragment">... to step through ...</p>
  361. <p>
  362. <span class="fragment">... a</span>
  363. <span class="fragment">fragmented</span>
  364. <span class="fragment">slide.</span>
  365. </p>
  366. </section>
  367. </div>
  368. </div>
  369. <script src="js/head.min.js"></script>
  370. <script src="js/reveal.js"></script>
  371. <script>
  372. // Full list of configuration options available at:
  373. // https://github.com/hakimel/reveal.js#configuration
  374. Reveal.initialize({
  375. controls: true,
  376. progress: true,
  377. history: true,
  378. center: true,
  379. transition: 'slide', // none/fade/slide/convex/concave/zoom
  380. // Optional reveal.js plugins
  381. dependencies: [
  382. { src: 'js/classList.js', condition: function() { return !document.body.classList; } },
  383. { src: 'js/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
  384. { src: 'js/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
  385. { src: 'js/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
  386. { src: 'js/zoom.js', async: true },
  387. { src: 'js/notes.js', async: true }
  388. ]
  389. });
  390. </script>
  391. </body>
  392. </html>