tungd / elixir-dns

DNS library for Elixir
BSD 3-Clause "New" or "Revised" License
114 stars 37 forks source link

Add example of how to use the server to send return codes #11

Closed doug-co closed 6 years ago

doug-co commented 6 years ago

I've been playing with the examples, and from looking at the readme, it isn't clear how I would return a not found or server error return code to a request.

I think it would be helpful to have an example.

Thanks!

doug-co commented 6 years ago

With a little more study of the code, my solution is as follows:

replace:

%{record | anlist: [resource]}

with:

case rcode do
  0 -> %{record | anlist: [resource]}
  _ -> %{record | header: %{ record.header | rcode: rcode }}
end

rcode is set at some point in the handle function to based on the server's response to the query.

If you think this would be helpful to others, please add to the README.md

tungd commented 6 years ago

Hi, this is just basic record update, I think people who are familiar with Elixir can figure this out themselves.