Code Monkey home page Code Monkey logo

cowpaths's Introduction

#cowpaths

Application that manages configuration of Cowboy.

Allows multiple applications to use a socket(s) without steppig on each others toes.

##Usage Start the application.

applicaiton:start(cowpaths).

###Create a socket to listen for requests

SocketSpec = #{
    port => integer()               :: Valid port integer, no default
    protocol => http|https|spdy|tls :: Protocol the cowboysocket should use. Corresponds 
                                       to cowboy:start_[protocol]. Default http
    protocol_options => []          :: The Cowboy socket options to use. Dispatch rules may be specified
                                       here but will be overwritten upon calling attach. Default []
    socket_options => []            :: The Socket options to use. Port will be automatically added to this list. 
                                       Default []
    workers => integer()            :: The number of socket acceptors to use. Default 50
}

cowpaths:socket(SocketSpec).

{ok, Socket} is returned when a socket is created. {exists, Socket} is returned when the port to use is already being managed.

###Attach to the socket Attach a HostTable to a series of sockets.

App = any() :: A unique term used to identify routes within the aplication.
Sockets = [integer()] | all :: A list of ints corresponding to the ports that have been bound by
                               calling cowpaths:socket(SocketSpec) or the atom all. If all is passed
                               the rules are applied to all 
Routes = [] :: Cowboy routes as described here: http://ninenines.eu/docs/en/cowboy/1.0/guide/routing/ |
               Trails or atom() that refer to modules that export trails/0 as described here:
                   https://github.com/inaka/cowboy-trails
cowpaths:attach(App, Sockets, Routes).

Routes are maintained on a per socket basis.

Each time attach is called the provided Routes are merged into the existing Routes for the sockets specified. As attached is called, the HostMatch constraints specified are merged into the sockets existing HostMatch constraints.

Within a socket/HostMatch pairing PathMatch specs must be unique. In the event that a specified PathMatch already exists attach will return {error, {"Path exists", PathMatch}}

###Detach from a socket Removes all Routes for App from all sockets.

cowpaths:detach(App).

###Check Configuration Returns the configuration as it is passed to Cowboy.

cowpaths:get_paths().

Build

$ rebar3 compile

cowpaths's People

Contributors

rleszilm avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.