Basic routing

It's time to extend our WebPart to support multiple routes. First, let's extract the WebPart and bind it to an identifier:

App.fs

   5: 
   6: 
   7: 
let webPart = OK "Hello World!" startWebServer defaultConfig webPart

In C#, one would call it "assign webPart to a variable", but in functional world there's really no concept of a variable. Instead, we can "bind" a value to an identifier, which we can reuse later. Values, once bound, can't be mutated during runtime.

namespace Suave
module Successful

from Suave
module Web

from Suave
val webPart : WebPart

Full name: SuaveMusicStore.webPart
val OK : body:string -> WebPart

Full name: Suave.Successful.OK
val startWebServer : config:SuaveConfig -> webpart:WebPart -> unit

Full name: Suave.Web.startWebServer
val defaultConfig : SuaveConfig

Full name: Suave.Web.defaultConfig

Show code from this section on GitHub

results matching ""

    No results matching ""