anchor.diff:  -module(mzb_api_endpoints).
   
   -export([init/2, info/3, terminate/3]).
  +
  +-include_lib("kernel/include/file.hrl").
   
   init(Req, _Opts) ->
       try
  
positive.code:         Filename = mzb_api_bench:log_file(Config),
          Headers = [{<<"content-type">>, <<"text/plain">>},
                     {<<"content-encoding">>, ContentEncoding}],
          Req2 = cowboy_req:chunked_reply(200, Headers, Req),
          stream_from_file(Filename, Id, Req2),
          {ok, Req2, #{}}
      end);
  
  handle(<<"GET">>, <<"/data">>, Req) ->
      with_bench_id(Req, fun(Id) ->
          #{config:= Config} = mzb_api_server:status(Id),
          #{metrics_compression:= Compression} = Config,
          ContentEncoding =
              case Compression of
  
negative.code:         {error, Reason} ->
              erlang:error({log_read_error, Reason})
      end.
  
  bench_finished(#{status:= failed}) -> true;
  bench_finished(#{status:= complete}) -> true;
  bench_finished(#{status:= stopped}) -> true;
  bench_finished(#{status:= _}) -> false.
  