Last active
August 29, 2015 14:17
-
-
Save eatonphil/e80ef65ea95cf3e9ef91 to your computer and use it in GitHub Desktop.
A Custom Response for User-Assigned Headers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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