Version 3 (#40)
Code for version 3
This commit was merged in pull request #40.
This commit is contained in:
24
src/JobsJobsJobs/Application/ApiHandlers.fs
Normal file
24
src/JobsJobsJobs/Application/ApiHandlers.fs
Normal file
@@ -0,0 +1,24 @@
|
||||
/// Route handlers for Giraffe endpoints
|
||||
module JobsJobsJobs.Api.Handlers
|
||||
|
||||
open System.IO
|
||||
open Giraffe
|
||||
open JobsJobsJobs.Common.Handlers
|
||||
open JobsJobsJobs.Domain
|
||||
|
||||
// POST: /api/markdown-preview
|
||||
let markdownPreview : HttpHandler = requireUser >=> fun next ctx -> task {
|
||||
let _ = ctx.Request.Body.Seek(0L, SeekOrigin.Begin)
|
||||
use reader = new StreamReader (ctx.Request.Body)
|
||||
let! preview = reader.ReadToEndAsync ()
|
||||
return! htmlString (MarkdownString.toHtml (Text preview)) next ctx
|
||||
}
|
||||
|
||||
|
||||
open Giraffe.EndpointRouting
|
||||
|
||||
/// All API endpoints
|
||||
let endpoints =
|
||||
subRoute "/api" [
|
||||
POST [ route "/markdown-preview" markdownPreview ]
|
||||
]
|
||||
Reference in New Issue
Block a user