README.md (1776B)
1 # Plug.Cowboy 2 3 [![Hex.pm Version](https://img.shields.io/hexpm/v/plug_cowboy.svg)](https://hex.pm/packages/plug_cowboy) 4 [![Build Status](https://github.com/elixir-plug/plug_cowboy/workflows/CI/badge.svg)](https://github.com/elixir-plug/plug_cowboy/actions?query=workflow%3ACI) 5 6 A Plug Adapter for the Erlang [Cowboy](https://github.com/ninenines/cowboy 7 ) web server. 8 9 ## Installation 10 11 You can use `plug_cowboy` in your project by adding the dependency: 12 13 ```elixir 14 def deps do 15 [ 16 {:plug_cowboy, "~> 2.0"}, 17 ] 18 end 19 ``` 20 21 You can then start the adapter with: 22 23 ```elixir 24 Plug.Cowboy.http MyPlug, [] 25 ``` 26 27 ## Supervised handlers 28 29 The `Plug.Cowboy` module can be started as part of a supervision tree like so: 30 31 ```elixir 32 defmodule MyApp do 33 # See https://hexdocs.pm/elixir/Application.html 34 # for more information on OTP Applications 35 @moduledoc false 36 37 use Application 38 39 def start(_type, _args) do 40 # List all child processes to be supervised 41 children = [ 42 {Plug.Cowboy, scheme: :http, plug: MyApp, port: 4040} 43 ] 44 45 # See https://hexdocs.pm/elixir/Supervisor.html 46 # for other strategies and supported options 47 opts = [strategy: :one_for_one, name: MyApp.Supervisor] 48 Supervisor.start_link(children, opts) 49 end 50 end 51 ``` 52 53 ## Contributing 54 55 We welcome everyone to contribute to Plug.Cowboy and help us tackle existing issues! 56 57 - Use the [issue tracker](https://github.com/elixir-plug/plug_cowboy/issues) for bug reports or feature requests. 58 - Open a [pull request](https://github.com/elixir-plug/plug_cowboy/pulls) when you are ready to contribute. 59 - Do not update the `CHANGELOG.md` when submitting a pull request. 60 61 ## License 62 63 Plug.Cowboy source code is released under Apache License 2.0. 64 Check the [LICENSE](./LICENSE) file for more information.