anchor.diff:  content_types_accepted(Req, State) ->
       {[{<<"application/json">>, from_json}], Req, State}.
   
  --spec malformed_request(cowboy:req(), state()) ->
  -    {boolean(), cowboy:req(), state()}.
  -malformed_request(Req, State) ->
  -    {Method, Req2} = cowboy_req:method(Req),
  -    malformed_request(Method, Req2, State).
  -
  -malformed_request(<<"POST">>, Req, State) ->
  -    {ok, Body, Req2} = cowboy_req:body(Req),
  -    case jsx:is_json(Body) of
  -        false ->
  -            {true, Req2, State};
  -        true ->
  -            JSON = jsx:decode(Body),
  -            ContainModuleName = proplists:is_defined(
  -                                  <<"scenario">>,
  -                                  JSON),
  -            ContainModuleSource = proplists:is_defined(
  -                                    <<"module_source">>,
  -                                    JSON),
  -
  -            case ContainModuleName and ContainModuleSource of
  -                true ->
  -                    ModuleName = proplists:get_value(
  -                                   <<"scenario">>,
  -                                   JSON),
  -                    ModuleSource = proplists:get_value(
  -                                     <<"module_source">>,
  -                                     JSON),
  -                    State2 = State#state{
  -                               module_name = ModuleName,
  -                               module_source = ModuleSource
  -                               },
  -                    {false, Req2, State2};
  -                false ->
  -                    {true, Req2, State}
  -            end
  -    end;
  -
  -malformed_request(_, Req, State) ->
  -    {false, Req, State}.
  -
  -
   %% Request processing functions
   
   -spec to_json(cowboy:req(), state()) -> 
  
positive.code: 
  
  -spec from_json(cowboy:req(), state()) ->
      {string() | halt | ok, cowboy:req(), state()}.
  from_json(Req0, State = #state{
                               module_name = ModuleName,
                               module_source = ModuleSource}) ->
      ScenarioPath = "scenarios/" ++ erlang:binary_to_list(ModuleName),
  
      file:write_file(
        ScenarioPath ++ ".erl",
        ModuleSource,
        [write]
       ),
      
      Result =
      case compile:file(ScenarioPath, [{outdir, ebin}]) of
          {ok, _} ->
              ok;
          error ->
              file:delete(ScenarioPath ++ ".erl"),
              error
      end,
  
      Reply = jsx:encode([{compile, Result}]),
      Req1 = cowboy_req:set_resp_body(Reply, Req0),
      {true, Req1, State}.
  
negative.code:          allowed_methods/2,
           content_types_provided/2,
           content_types_accepted/2,
           to_json/2,
           from_json/2]).
  
  