I had a few ideas I put together and would appreciate some feedback.  A lot of it revolves around Java 8 but I kept all of the extensions themselves at Java 7.  The main goal of Java 8 was to make constructing HttpHandlers easier when you delegate to other handlers.

Example:
Handlers.routing()
         .add(Methods.GET, "/messages", HandlerBuilder
             .create(CustomHandlers.json(Messages::getMessages))
                .wrap(CustomHandlers::timing, "getMessages")
            .wrap(BlockingHandler::new)
             .build()) 

Here is my branch https://github.com/billoneil/undertow/tree/feature/ext

Here is the entry point to an example that puts it all together. https://github.com/billoneil/undertow/blob/feature/ext/ext/examples/src/main/java/io/undertow/ext/examples/rest/RestServer.java

Please excuse the boring example I couldn't think of anything interesting. 

If you run it locally


curl -X POST localhost:8080/messages/optional -d '{"title": "Optional", "message": "Using optional"}'
{"success":true}

curl -X POST localhost:8080/messages/lambda -d '{"title": "Lambda", "message": "Using Lambda"}'
{"success":true}

curl -X POST localhost:8080/messages -d '{"title": "Method References", "message": "Using method references"}'
{"success":true}

curl -X GET localhost:8080/messages
[
  • {
    • title"Optional",
    • message"Using optional"
    },
  • {
    • title"Lambda",
    • message"Using Lambda"
    },
  • {
    • title"Method References",
    • message"Using method references"
    }
]

curl -X GET localhost:8080/info/metrics
{
  • version"3.0.0",
  • gauges: { },
  • counters: { },
  • histograms: { },
  • meters
    {
    • response.status.code.200
      {
      • count8,
      • m15_rate21.787938213503697,
      • m1_rate6.5304307794735275,
      • m5_rate18.017228623496,
      • mean_rate4.457584495510739,
      • units"events/minute"
      }
    },
  • timers
    {
    • createMessageLambda
      {
      • count1,
      • max1.169,
      • mean1.169,
      • min1.169,
      • p501.169,
      • p751.169,
      • p951.169,
      • p981.169,
      • p991.169,
      • p9991.169,
      • stddev0,
      • m15_rate0.059490549916151686,
      • m1_rate0.1812199126454006,
      • m5_rate0.14211865026090975,
      • mean_rate0.5343847126926461,
      • duration_units"milliseconds",
      • rate_units"calls/minute"
      },
    • createMessageMethodReferences
      {
      • count1,
      • max0.648,
      • mean0.648,
      • min0.648,
      • p500.648,
      • p750.648,
      • p950.648,
      • p980.648,
      • p990.648,
      • p9990.648,
      • stddev0,
      • m15_rate0.05982197273776584,
      • m1_rate0.19696865690816925,
      • m5_rate0.14450714325124409,
      • mean_rate0.5343791108783038,
      • duration_units"milliseconds",
      • rate_units"calls/minute"
      },
    • createMessageOptional
      {
      • count1,
      • max94.579,
      • mean94.579,
      • min94.579,
      • p5094.579,
      • p7594.579,
      • p9594.579,
      • p9894.579,
      • p9994.579,
      • p99994.579,
      • stddev0,
      • m15_rate10.678581251856285,
      • m1_rate2.0852873214053433,
      • m5_rate8.456257076624562,
      • mean_rate0.5343875445806129,
      • duration_units"milliseconds",
      • rate_units"calls/minute"
      },
    • getMessages
      {
      • count3,
      • max9.809999999999999,
      • mean3.6413333333333333,
      • min0.514,
      • p500.6,
      • p759.809999999999999,
      • p959.809999999999999,
      • p989.809999999999999,
      • p999.809999999999999,
      • p9999.809999999999999,
      • stddev5.342395093339066,
      • m15_rate0.18767034671569677,
      • m1_rate1.2185014871528328,
      • m5_rate0.49650226189858143,
      • mean_rate1.6030845484157583,
      • duration_units"milliseconds",
      • rate_units"calls/minute"
      },
    • getMetrics
      {
      • count0,
      • max0,
      • mean0,
      • min0,
      • p500,
      • p750,
      • p950,
      • p980,
      • p990,
      • p9990,
      • stddev0,
      • m15_rate0,
      • m1_rate0,
      • m5_rate0,
      • mean_rate0,
      • duration_units"milliseconds",
      • rate_units"calls/minute"
      }
    }
}






On Thu, Jul 3, 2014 at 9:28 AM, Bill O'Neil <bill@dartalley.com> wrote:
I have mostly just been getting familiar with undertow for side projects.  I would be happy to share anything I come up with though to get some feedback.


On Wed, Jul 2, 2014 at 10:44 AM, Jason Greene <jason.greene@redhat.com> wrote:
On Jul 2, 2014, at 9:02 AM, Bill O'Neil <bill@dartalley.com> wrote:

> Is there any plan to open up an undertow-ext library where the community can make small modules that hook into 3rd party dependencies?  For example, an HttpHandler that uses Jackson/Gson to serialize to json and set appropriate headers, or an HTML templating framework for rendering HTML.
>
> Would you prefer these to be hosted by 3rd parties instead?

I think this is a great idea. Are you interested in being a maintainer of such a thing?

--
Jason T. Greene
WildFly Lead / JBoss EAP Platform Architect
JBoss, a division of Red Hat