Cookoo, The Chain-of-Command Controller for Go

Cookoo is a high performance reusable controller pattern that can be used to build console (CLI) applications, API servers, middle ware, integration tests, bots, and web applications.

Think of Cookoo as a better front-controller:

Since commands are re-usable, you can begin with existing commands, add your own, and rapidly assemble a collection of components that can simply and speed up application development.

Getting Started with Hello World

Here is a dead-simple Cookoo "Hello World" command line app.

package main

import (

func main() {

    // Build a new Cookoo app.
    registry, router, context := cookoo.Cookoo()

    // For the route TEST execute a single command HelloWorld.
    // The registry stores the mapping of routes to commands.
    registry.Route("TEST", "A test route").Does(HelloWorld, "hi")

    // Execute the route.
    router.HandleRequest("TEST", context, false)

func HelloWorld(cxt cookoo.Context, params *cookoo.Params) interface{} {
    fmt.Println("Hello World")
    return true

When creating a new cookoo based application there are tree main parts:

  1. Registry: contains the mapping of commands to callbacks along with how information is passed around the context.
  2. Router: handles incoming requests and routes them to the correct callback on the registry. Different types of applications will have different routers. Commands coming in from a REST application or a CLI will happen differently. Cookoo includes routers for REST and console applications.
  3. Context: an execution context passed through the chain of commands as they are executed. It contains information passed around the application along with access to other useful functions such as data sources and logging.

But Cookoo can be used for much more than just command line apps. We use it for:

...and that's just what we've done with it so far.

To learn more about cookoo, check out the extensive Go documentation. And we're just getting started on the tutorial documentation. Check out the doc/ directory in our Git repository to view our work-in-progress.