https://github.com/rflechner/tinyrest
A tiny FSharp and CSharp Rest server
https://github.com/rflechner/tinyrest
Last synced: 12 months ago
JSON representation
A tiny FSharp and CSharp Rest server
- Host: GitHub
- URL: https://github.com/rflechner/tinyrest
- Owner: rflechner
- Created: 2015-06-26T13:35:34.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-06-23T08:34:31.000Z (almost 10 years ago)
- Last Synced: 2025-06-08T22:39:50.862Z (about 1 year ago)
- Language: F#
- Homepage: https://rflechner.github.io/TinyRest/
- Size: 3.66 MB
- Stars: 10
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TinyRest
A tiny FSharp and CSharp Rest server written in F#
## Install
A nuget package exists hehe: https://www.nuget.org/packages/TinyRest/
PM> Install-Package TinyRest
## Usage in FSharp
There an example of a simple file server here:
https://github.com/rflechner/TinyRest/blob/master/TinyRest/TinyRest/TinyRestServer-sample.fsx
let routes = [
GET (Path("/")) <| fun q r -> text "coucou"
get "/bye" <| fun q r -> text "bye bye\n@++"
getPattern "/haha/(.*)" <| fun q r -> text "ha ha"
GET (Path("/files")) <| listFiles
get "/download" <| download
]
let conf = { Schema=Http; Port=8009; BasePath=Some "/TinyRest1"; Routes=routes; }
listen conf
Console.Read () |> ignore
## Usage in CSharp
class Program
{
private static int count = 0;
private static void Main(string[] args)
{
TinyRestServerCSharp.TinyRest.Server()
.WithHttp()
.WithPort(8001)
.WithBasePath("/learning")
.OnGetPath("/", (request, response) => "coucou " + (count++))
.OnGetPath("/json", (request, response) => response.Json(new
{
Text = "coucou " + (count++)
}))
.Create()
.Listen();
Console.Read();
}
}