lfe-mug / lmug

LFE HTTP Server Abstraction and Web Application Middleware Infrastructure
20 stars 3 forks source link

Create lmug-adptr module and behaviour #26

Closed oubiwann closed 6 months ago

oubiwann commented 8 years ago

I'll look at the Ring Jetty servlet example for inspiration, and then look at what we're doing with the Elli lmug adaptor, what I've done with Barista & YAWS, what I want to do with lmug-inets, and then we should have a pretty good idea where to go with this.

oubiwann commented 8 years ago

A Review of Adapters/Adaptors

Ring servlet

The following public functions seem to be the crucial ones in the Ring servlet example:

Jetty

jetty just has one public function:

but it has other supporting functions that provide useful operations, many of which make calls to the Ring servlet code.

Ring Server

ring-server provides the following:

Previous lmug work

Barista:

lmug-yaws:

lmug-elli ("develop" branch):

oubiwann commented 8 years ago

Tentative thoughts on behaviour functions (question marks are due to undefined arities right now):

Update: this recommendation owes most of its inspiration to the Ring servlet and the lmug-elli adaptor.

I think a separate behaviour could be defined for an actual lmug HTTP server (as opposed to an adaptor).

oubiwann commented 8 years ago

I'm toying with this, more explicit, set of names now:

(defmodule lmug-adptr
  (export all))

(defun behaviour_info
  (('callbacks)
    '(#(convert-request 1) #(convert-request 2)
      #(convert-response 1) #(convert-response 2)
      #(convert-handler 1) #(convert-handler 2)))
  ((_)
    'undefined))
yurrriq commented 8 years ago

Per our conversation in Slack, :+1: to lmug->* and *->lmug. convert-* feels a bit ambiguous to me.

convert-request and convert-response for now.

oubiwann commented 8 years ago

Okay, we've chatted a bunch about this tonight on Slack ... here's the latest update to the behaviour that worked for me this weekend:

(defmodule lmug-adptr
  (export all))

(defun behaviour_info
  (('callbacks)
    '(#(convert-request 1) #(convert-request 2)
      #(convert-response 1) #(convert-response 2)
      #(call-handler 1) #(call-handler 2)))
  (('optional_callbacks)
    '(#(set-handler 1)
      #(get-handler 0)))
  ((_)
    'undefined))

Definitely still evolving, though ...