0

だから、このオパのことが取り上げられています。
次のようにサーバーを起動します。

    function resource request_dispatch(Uri.relative p_url,
                                       p_log_fun) {
            //type Uri.relative = {list(string) path, list((string,string)) query }
            match (p_url) {
                case {path: [] ... }              : get_standard_page(p_log_fun);
                case {path: ["_rest_" | path] ...}: api_request_handler(path,p_log_fun);
                case {~path ...}                  : Resource.page("Regular",<div>standard page</div>);
            }
        }     
function start_server(p_log_fun) {
            function resource dispatch_handler_fun(Uri.relative p_url) {
                request_dispatch(p_url,p_log_fun)
            }
            Server.start(Server.http,
                         { title   : "Hello, world",
                           dispatch:dispatch_handler_fun})
        }

しかし、私は得ています:

エラー: ファイル "src/posts_viewer.opa"、行 71、文字 3 ~ 150、(71:3-74:42 | 2466-2613)
Type Conflict
(72:10-74:41) {dispatch: (Uri.relative -> リソース); title: string } /
'ca
(71:3-71:8) Server.handler function
の 2 番目の引数は、
{dispatch: (Uri.relative -> resource);の型である必要があります。タイトル: 文字列 } / 'ca の
代わりに
Server.handler

したがって、明らかにdispatch_handler_funは正しい型シグネチャではありません。API ドキュメントでは、バリアントhttp://doc.opalang.org/type/stdlib.core.web.server/Server/handlerで Server.handler を見ることができ ます

ここでdispatch_handler_funが適切でない理由は誰にも明らかですか?
ps。悪いコード形式で申し訳ありません:)

ありがとうございました

4

1 に答える 1