func main() { pelau.DefaultRouter(). Get(pelau.Static("/static/get", handler)). Post(pelau.Static("/static/post", handler)). Put(pelau.Static("/static/put", handler)). Head(pelau.Static("/static/head", handler)). Delete(pelau.Static("/static/delete", handler)). Get(pelau.Regex("/regex/[a-zA-Z0-9]+", handler)). Post(pelau.Regex("/regex/[a-zA-Z0-9]+", handler)). Put(pelau.Regex("/regex/[a-zA-Z0-9]+", handler)). Head(pelau.Regex("/regex/[a-zA-Z0-9]+", handler)). Delete(pelau.Regex("/regex/([a-zA-Z0-9]+)", handler)). Use(mid.JSONEncoding). Use(func(req pelau.Request, res pelau.Response, c *pelau.Context) { fmt.Println("This message will print regardless of what request method was used.") c.Next(req, res, c) }). Bind("127.0.0.1:8080", func() { fmt.Println("Sever started.") }) }
r.flag = true return true } var _ = Describe("DefaultRouter", func() { var ( router pelau.Router server *httptest.Server mockCtl *gomock.Controller called bool ) BeforeEach(func() { router = pelau.DefaultRouter() mockCtl = gomock.NewController(gomocktestreporter.New()) server = httptest.NewServer(router) called = false }) AfterEach(func() { defer server.Close() }) Describe("using middleware", func() { BeforeEach(func() {