Spooky
Minimum viable Erlang web framework
Install / Use
/learn @flashingpumpkin/SpookyREADME
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 yourgen_servers,gen_fsmsandgen_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.
Related Skills
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
