[erlang-questions] Including function in configuration file

Roger Lipscombe roger@REDACTED
Mon Jul 9 21:50:14 CEST 2018


On 9 July 2018 at 20:16, Code Wiget <codewiget95@REDACTED> wrote:
> So, for the ssl options such as:
> {reuse_session, fun()} {next_protocols_advertised, [binary()]}
>
> {user_lookup_fun, {fun(), term()}}, {psk_identity, string()}, {srp_identity,
> {string(), string()}}
>
> You have to manually set the configuration parameters, and cannot set them
> in a configuration file?

Yes, but you _can_ come up with some other way to specify them in the
configuration file, and then convert that to an actual function before
you pass it to SSL options.

We have something like this in our code:

convert_ssl_opt({verify_opts, VerifyOpts}, Acc) ->
    Opt = {verify_fun, {fun do_verify/3, VerifyOpts}},
    [Opt | Acc];

...which converts our invented 'verify_opts' into the required
'verify_fun', by using a do_verify function in the module that does
the conversion.



More information about the erlang-questions mailing list