Skip to content

Instantly share code, notes, and snippets.

@eatonphil
Last active August 29, 2015 14:17
Show Gist options
  • Save eatonphil/e80ef65ea95cf3e9ef91 to your computer and use it in GitHub Desktop.
Save eatonphil/e80ef65ea95cf3e9ef91 to your computer and use it in GitHub Desktop.
A Custom Response for User-Assigned Headers
open OWebl
open Rule
open Server
open Mycustomresponse
let handler =
Handler.create
(StaticRouteRule.create "/" [Verb.GET])
(MyCustomResponse.create "Hello World!" []) (*headers go here*)
let server = SimpleServer.serve [handler]
module MyCustomResponse = struct
include Response
let my_custom_http_response (u_response: string) (u_headers: string list) : Response.r =
http_response u_response "200 OK" "text/html" "utf-8" u_headers
class my_custom_response (u_response: string) (u_headers: string list) =
object
method get_response (request: Request.t) : r =
my_custom_http_response u_response u_headers
end
let create (u_response: string) (u_headers: string list) =
new simple_response u_response u_headers
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment