anchor.diff:    start_link/1
   ]).
   
  -% Internal API
  -% -export ([terminate/2]).
  -
   -record(state, {
     subdomain,        % subdomain of the app to look for
     backend,          % Backend
  
positive.code:     exit(error)
    end.
  
  
  engage_backend(ClientSock, RequestPid, Hostname, Req, {ok, #backend{host = Host, port = Port} = Backend}) ->
    SockOpts = [  binary, 
                  {nodelay, true},
  
negative.code:   timeout           % timeout
  }).
  
  % Start the proxy by spawning off an init with the socket.
  % Compatible with the supervisor behaviour
  start_link(ClientSock) ->
    Pid = spawn_link(fun() -> proxy_init(ClientSock) end),
    {ok, Pid}.
  
  % Receive the initial request and socket. Use the packet_decoder (http for now) to decode the
  % routing key required. If this can be found, then start engaging the backend.
  % If this takes more than IDLE_TIMEOUT seconds, then exit with an error.
  proxy_init(ClientSock) ->
    receive
      {start, ClientSock, RequestPid} ->
  