anchor.diff:  %% End of REST callbacks. Whew!
   
   -record(state, {
  -	env :: cowboy_middleware:env(),
   	method = undefined :: binary(),
   
   	%% Handler.
  
positive.code: 		{state, HandlerState}
  	]}).
  
  terminate(Req, #state{env=Env, handler=Handler, handler_state=HandlerState}) ->
  	Result = cowboy_handler:terminate(normal, Req, HandlerState, Handler),
  	{ok, Req, [{result, Result}|Env]}.
  
negative.code: 
  -spec upgrade(Req, Env, module(), any(), infinity, run)
  	-> {ok, Req, Env} when Req::cowboy_req:req(), Env::cowboy_middleware:env().
  upgrade(Req0, Env, Handler, HandlerState, infinity, run) ->
  	Method = cowboy_req:method(Req0),
  	{ok, Req, Result} = service_available(Req0, #state{method=Method,
  		handler=Handler, handler_state=HandlerState}),
  	{ok, Req, [{result, Result}|Env]}.
  
  service_available(Req, State) ->
  	expect(Req, State, service_available, true, fun known_methods/2, 503).
  