Coder Social home page Coder Social logo

spooky's Introduction

Spooky Spooky

Synopsis

Spooky is a lightweight and dead easy to use RESTful request handler for Erlang.

It's using the Misultin http library and provides request handling similar to the Sinatra web framework.

hello_world.erl

    -module(hello_world).
    -behaviour(spooky).
    -export([init/1, get/2]).

    init([])->
        [{port, 8000}].

    get(Req, [])->
        Req:ok("Hello world.");
    get(_, ["smashingpumpkins"])->
        throw({418, "I'm a teapot."});
    get(Req, [Name])->
        Req:ok("Hello world, " ++ Name ++ ".").

shell

    $ make && erlc -pa ebin/ hello_world.erl && erl -pa ebin/ -pa deps/*/ebin
    [...]
    1> spooky:start_link(hello_world)
    {ok, <0.40.0>}
    2> spooky:stop()
    true

Features

  • Modular
    Split your web application up into different, reusable modules. Say, for user management, mnesia administration or login logic.

  • RESTful request handling/routing

    • Use get/post/put/delete/head methods for a clean seperation of your HTTP API
    • Use pattern matching to handle requests to different URLs
  • Middlewares
    Use chained middlewares to preprocess the request before it arrives at your handlers and modify or abort it on the fly.

  • Erlang
    Dead simple interfacing to your gen_servers, gen_fsms and gen_events

Todo

  • Write documentation

Why?

Scratching an itch. Spooky is as simple as it gets - you're left to deal with everything else than request handling. If this is not what you are looking for and need things like ORM support, templating, etc, you should look at other frameworks:

Thanks

Thanks to Learn you some Erlang, Mochiweb, Misultin and CouchDB for being excellent repositories to learn about Erlang.

spooky's People

Contributors

bluegraybox avatar flashingpumpkin 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.