gdritter repos cube-cotillion / master
Some of a README Getty Ritter 8 years ago
1 changed file(s) with 65 addition(s) and 0 deletion(s). Collapse all Expand all
1 **CAUTION: DO NOT USE THIS SOFTWARE**
2
3 The `cube-cotillion` library is a heavily Scotty-inspired framework
4 for writing services over SSH.
5
6 # Example
7
8 This example allows anyone to authenticate, and responds to two
9 commands, `greet` and `greet [name]`, with a short greeting.
10
11 ~~~.haskell
12 {-# LANGUAGE OverloadedStrings #-}
13
14 module Main where
15
16 import Data.Monoid (mconcat)
17 import Network.CubeCotillion
18
19 main :: IO ()
20 main = do
21 key <- loadKey "server-keys"
22 cubeCotillion 8080 key $ do
23 cmd "greet" $ do
24 bs "Hello, world!\n"
25 cmd "greet :name" $ do
26 name <- param "name"
27 bs $ mconcat ["Hello, ", name, "!\n"]
28 ~~~
29
30 While running this service on localhost, we can connect to and
31 use it like so:
32
33 ~~~
34 [gdritter@mu ~]$ ssh -p 8080 localhost greet
35 Hello, world!
36 [gdritter@mu ~]$ ssh -p 8080 localhost greet Eberhardt
37 Hello, Eberhardt!
38 ~~~
39
40 # Why?
41
42 HTTP is often used as a protocol for exposing certain kinds of
43 services, but HTTP also lacks certain kinds of built-in features,
44 which are often reimplemented in various different ways: for
45 example, connection multiplexing, compression of conveyed
46 information, and user authentication and identity. All of these
47 are features trivially supported by the SSH protocol already.
48 Additionally, tools for working with SSH are ubiquitous, and
49 developers often already have existing SSH identities.
50
51 That doesn't necessarily mean that SSH is a great protocol to
52 use to build services on top of. I frankly don't _know_ if
53 that would be a good idea or not! That's why `cube-cotillion`
54 exists: to experiment with building these kinds of services
55 in a quick and easy way.
56
57 # Why The Name?
58
59 The design of the library is heavily inspired by the
60 lightweight Haskell web frameworks
61 [Scotty](http://hackage.haskell.org/package/scotty) and
62 [Spock](http://hackage.haskell.org/package/Spock), both
63 of which are named after Star Trek Characters. I figured
64 I should follow suit, and choose the name of one of my
65 [favorite Star Trip characters, too](https://www.youtube.com/watch?v=O2XOLoeBPEk).