Application
is a root router that implemented http.Handler
interface.
app := clevergo.New()
app.Get("/", func(c *clevergo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
})
app.Run(":8080")
GET
request handler.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
.
Middleware can be plugged into the Application via Use
method.
app.Use(
middlewareFoo,
middlewarebar,
// ...
)
Checkout the Middleware for details.
app.Run(addr)
app.Run(addr, certFile, keyFile)
app.RunUnix("/tmp/app.sock")