How to Create a Cowboy Middleware Add an entry to the middlewares. Usually you want to keep the standard Cowboy handlers afterwards, but you can replace them if you want. {ok, Pid} = cowboy:start_clear(ListenerName, [{port, Port}], #{ env => #{dispatch => Dispatch},