Application

Application is a root router that implemented http.Handler interface.

Usage

app := clevergo.New()
app.Get("/", func(c *clevergo.Context) error {
    return c.String(http.StatusOK, "Hello, World!")
})
app.Run(":8080")
  1. Create an application.
  2. Register a GET request handler.
  3. Start a HTTP service that listening on 8080 port.

New creates an Application which enables Logging, ErrorHandler, Recovery and ServerHeader middlewares. You can also create a pure Application without any middlewares via Pure.

Middldeware

Middleware can be plugged into the Application via Use method.

app.Use(
    middlewareFoo,
    middlewarebar,
    // ...
)

Checkout the Middleware for details.

Start Server

HTTP

app.Run(addr)

HTTPS

app.Run(addr, certFile, keyFile)

Unix

app.RunUnix("/tmp/app.sock")
comments powered by Disqus