OCaml에서 간단한 웹 서버를 만드는 법을 설명하는 lwt
및 Cohttp
의 튜토리얼을 따르고 있습니다.Error : 언 바운드 레코드 필드 Server.callback - Ocaml
true: package(lwt), package(cohttp), package(cohttp.lwt)
그리고 webserver.ml
:
_tags
파일이
Error: Unbound record field callback
Command exited with code 2.
내가 변경하는 경우 : 다음
open Lwt
open Cohttp
open Cohttp_lwt_unix
let make_server() =
let callback conn_id req body =
let uri = Request.uri req in
match Uri.path uri with
| "/" -> Server.respond_string ~status:`OK ~body:"hello!\n"()
| _ -> Server.respond_string ~status:`Not_found ~body:"Route not found"()
in
let conn_closed conn_id() =() in
Server.create { Server.callback; Server.conn_closed }
let _ =
Lwt_unix.run (make_server())
을 ocamlbuild -use-ocamlfind webserver.native
다음과 같은 오류를 트리거 까지 : Server.create { callback; conn_closed }
답 :
Error: Unbound record field callback
Command exited with code 2.
이 문제를 해결하는 방법에 대해 잘 모르겠습니다. 미리 조사해 주셔서 감사합니다.
을! 매우 상세한 답변을 주셔서 감사합니다. –