The Pico Erlang server
For the following link to work, the shell command
start_4501 must have been given.
API
The pico web server is accessed through the module
pico_http_server.erl - this has the following interface:
- pico_http_server:start(Port, Max, Mod, Args) -> bool()
- Start a http server.
Port is the port number for the
server.
Max in the maximum number of simultaneous connections to the
server.
Mod is the name of a callback module.
Args are arguments to the callback module.
- pico_http_server:stop(Port, Reason) -> State
- Stops the server
Callbacks
The callback module (Mod in the above) must export the
following routines:
- start_handler(Arg) -> State
- Arg is a list of the arguments supplied in the start
call.
Returns State.
- event_handler(Event, State) -> {Reply, State'}
- Event handler. Event is a parse tree representing an HTTP
GET or PUT event. State is the last returned value from either
a start_handler or event_handler. Returns a string to be
sent back to the server and a new state.
- stop(Reason, State) -> State'
- Terminate the server. Reason is the reason for
termination. State is the last returned value from either
a start_handler or event_handler. Returns a new state.