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: |
|
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
from Suave
module Web
from Suave
from Suave
val webPart : WebPart
Full name: SuaveMusicStore.webPart
Full name: SuaveMusicStore.webPart
val OK : body:string -> WebPart
Full name: Suave.Successful.OK
Full name: Suave.Successful.OK
val startWebServer : config:SuaveConfig -> webpart:WebPart -> unit
Full name: Suave.Web.startWebServer
Full name: Suave.Web.startWebServer
val defaultConfig : SuaveConfig
Full name: Suave.Web.defaultConfig
Full name: Suave.Web.defaultConfig
Show code from this section on GitHub