Wynn Netherland changelog.com/posts

Falcore - modular HTTP server framework for Go

Dave Grijalva and Scott White from the engineering team at mobile app maker ngmoco have released Falcore a module HTTP server for Go. With built-in logging and performance tracking, Falcore provides hot restarts in a modular architecture. Much like Rack middleware stacks, Falcore components are written as request or response filters and arranged into upstream or downstream pipelines. HTTP requests can call pipelines conditionally via Falcore routers, as seen in this architecture diagram:

Falcore architecture

The GitHub repo contains a number of examples, including an obligatory Hello World server:

package main
import (
  "http"
  "flag"
  "fmt"

  "falcore"
)
// Command line options
var (
  port = flag.Int("port", 8000, "the port to listen on")
)

func main() {
  // parse command line options
  flag.Parse()

  // setup pipeline
  pipeline := falcore.NewPipeline()

  // upstream
  pipeline.Upstream.PushBack(helloFilter)

  // setup server
  server := falcore.NewServer(*port, pipeline)

  // start the server
  // this is normally blocking forever unless you send lifecycle commands 
  if err := server.ListenAndServe(); err != nil {
    fmt.Println("Could not start server:", err)
  }
}

var helloFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Response {
  return falcore.SimpleResponse(req.HttpRequest, 200, nil, "hello world!")
})

The ngenunity blog has more background in the announcement post.


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00