Skip to content

Commit

Permalink
Increase idle timeout (#123)
Browse files Browse the repository at this point in the history
* Set idle_timeout to 10 minutes

* fix typo in README

* fix indentation
  • Loading branch information
hanssv authored Jul 6, 2023
1 parent 672d984 commit edd95c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ other contracts.
We can now compile the contract and get the bytecode:

```
url -H "Content-Type: application/json" -d "{\"code\":\"$contract\", \"options\":{}}" -X POST http://localhost:3080/compile
curl -H "Content-Type: application/json" -d "{\"code\":\"$contract\", \"options\":{}}" -X POST http://localhost:3080/compile
```
Returns:
```
Expand Down
14 changes: 6 additions & 8 deletions apps/aesophia_http/src/aesophia_http_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ start(_StartType, _StartArgs) ->
Paths = get_paths(),
{ok,Port} = application:get_env(port), %Get the port
logger:info("Port: ~p", [Port]),
Dispatch = cowboy_router:compile([
{'_',Paths}
]),
{ok,_} = cowboy:start_clear(http, [{port,Port}],
#{env => #{dispatch => Dispatch},
middlewares => [cowboy_router,
aesophia_cors_middleware,
cowboy_handler]}),
Dispatch = cowboy_router:compile([{'_', Paths}]),
Middlewares = [cowboy_router, aesophia_cors_middleware, cowboy_handler],
{ok, _} = cowboy:start_clear(http, [{port, Port}],
#{env => #{dispatch => Dispatch},
middlewares => Middlewares,
idle_timeout => 10 * 60000}),
aesophia_http_sup:start_link().

%%--------------------------------------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions apps/aesophia_http/src/aesophia_http_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ handle_request('CompileContract', Req, _Context) ->
#{ <<"code">> := Code } = Json } ->
Options = maps:get(<<"options">>, Json, #{}),
case compile_contract(Code, Options) of
{ok, ByteCode, Aci} ->
ByteCodeEncoded = aeser_api_encoder:encode(contract_bytearray, ByteCode),
{200, [], #{bytecode => ByteCodeEncoded, aci => Aci}};
{error, Errors} when is_list(Errors) ->
{400, [], mk_errors(Errors)};
{error, Msg} when is_binary(Msg) ->
{400, [], mk_error_msg(Msg)}
{ok, ByteCode, Aci} ->
ByteCodeEncoded = aeser_api_encoder:encode(contract_bytearray, ByteCode),
{200, [], #{bytecode => ByteCodeEncoded, aci => Aci}};
{error, Errors} when is_list(Errors) ->
{400, [], mk_errors(Errors)};
{error, Msg} when is_binary(Msg) ->
{400, [], mk_error_msg(Msg)}
end;
_ -> {400, [], bad_request()}
end;
Expand Down

0 comments on commit edd95c5

Please sign in to comment.