https://github.com/kfl/webserver-functor
Example code demonstrating how SML modules, in particular functors, can be used for structuring a web framework.
https://github.com/kfl/webserver-functor
Last synced: 5 months ago
JSON representation
Example code demonstrating how SML modules, in particular functors, can be used for structuring a web framework.
- Host: GitHub
- URL: https://github.com/kfl/webserver-functor
- Owner: kfl
- Created: 2014-02-26T13:16:56.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-02-26T13:17:17.000Z (over 12 years ago)
- Last Synced: 2025-06-10T10:49:12.640Z (about 1 year ago)
- Language: Standard ML
- Size: 102 KB
- Stars: 13
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
App Webserver As a Functor
==========================
Example code demonstrating how SML modules, in particular functors,
can be used for structuring a web framework.
The code in its current state is only useful for demonstration, it is
**not** ready for production. Also, it's probably a bit far fetched to
call the current code a "framework".
Architecture
------------
The overall idea is that you make a web-application by implementing a
structure, say `App`, with the signature `WebApp`. Then you give `App`
to a functor which will then take care of creating a web server (or in
communicate with one).
The framework consists of two files:
* `HtmlUtils.sml` contains a structure `HtmlUtils` where the type
`reply` for HTTP replies is declared, the module also contains some
simple-mined (read inefficient) utility functions for creating HTML
pages.
* `WebServerFct.sml` contains the signature `WebApp` and the functor
`WebServerFct`.
Examples
--------
Compile the examples with the command:
~~~
$ mosmlc -toplevel HtmlUtils.sml WebServerFct.sml App.sml -o appserver
~~~
Where `App.sml` is the example you want to compile.
* `CountingEcho.sml` an echo server, that also counts how many
times it has been called.
* `PhonebookApp.sml` an phonebook with shared state across clients.
Uses an in-memory "database" implemented as a list.
Shows how to deal (rudimentary) with the query
path of an URL ().