forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
FSharp
Demis Bellot edited this page Jul 10, 2013
·
9 revisions
Thanks to the simplicity, elegance, strong typing and philosophy of both solutions, FSharp and ServiceStack are quickly becoming a popular choice for creating friction-less REST and message-based remote services.
open System
open ServiceStack.ServiceHost
open ServiceStack.WebHost.Endpoints
type Hello = { mutable Name: string; }
type HelloResponse = { mutable Result: string; }
type HelloService() =
interface IService with
member this.Any (req:Hello) = { Result = "Hello, " + req.Name }
//Define the Web Services AppHost
type AppHost =
inherit AppHostHttpListenerBase
new() = { inherit AppHostHttpListenerBase("Hi F#!", typeof<HelloService>.Assembly) }
override this.Configure container =
base.Routes
.Add<Hello>("/hello")
.Add<Hello>("/hello/{Name}") |> ignore
//Run it!
[<EntryPoint>]
let main args =
let host = if args.Length = 0 then "http://*:1337/" else args.[0]
printfn "listening on %s ..." host
let appHost = new AppHost()
appHost.Init()
appHost.Start host
Console.ReadLine() |> ignore
0
- Last-Fi (F#, Raspberry Pi, Last.Fm, FunScript and ServiceStack) by @pezi_pink
- ServiceStack, With F# on Linux (inc Vagrant / Puppet) by @mattdrivendev
- Declarative authorization in REST services in SharePoint with F# by @sergey_tihon
- ServiceStack and F# on Heroku (GitHub) by @kunjee
- First hand experience with F# by @d4dilip
- ServiceStack: New API – F# Sample by @sergey_tihon
- Async, Cached Twitter API Proxy in F# by @demisbellot
- F# Web Services on any platform in and out of a web server! by @demisbellot
- Why ServiceStack?
- What is a message based web service?
- Advantages of message based web services
- Why remote services should use separate DTOs
- Getting Started
- Reference
- Clients
- Formats
- View Engines 4. Razor & Markdown Razor
- Hosts
- Advanced
- Configuration options
- Access HTTP specific features in services
- Logging
- Serialization/deserialization
- Request/response filters
- Filter attributes
- Concurrency Model
- Built-in caching options
- Built-in profiling
- Messaging and Redis
- Form Hijacking Prevention
- Auto-Mapping
- HTTP Utils
- Virtual File System
- Config API
- Physical Project Structure
- Modularizing Services
- Plugins
- Tests
- Other Languages
- Use Cases
- Performance
- How To
- Future