ce036f428d
This is an initial spike on how the middleware might be included into the system. It is inspired/copied from GIN, so I still have to work out, how to make it nicer than it is at the moment. What is currently missing is Aborting and the addRoute function looks very ugly.
18 lines
329 B
Go
18 lines
329 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gibheer/zero-blog/lib"
|
|
"github.com/gibheer/zero-blog/controller"
|
|
)
|
|
|
|
func main() {
|
|
router := lib.NewRouter()
|
|
router.Use(func(c *lib.Context) error {
|
|
fmt.Fprint(c.Response, "Hello says the middleware!")
|
|
return nil
|
|
})
|
|
controller.DefineRoutes(router)
|
|
router.Start()
|
|
}
|