func ExampleMount() { app := uweb.NewApp() app.Get("^bar/(.*)", func(name string) string { return "Hello, " + name }) uweb.Mount("^foo/", app) uweb.Run("localhost:6060") }
// This example demonstrates a custom instance of App. func ExampleApp() { app := uweb.NewApp() app.Get("^hello/(.*)", func(name string) string { return "Hello, " + name }) app.Post("^submit/$", func(ctx *uweb.Context) { }) app.Run("localhost:6060") }
func init() { uweb.Config.Logging = false app = uweb.NewApp() app.Route("^view1/$", simpleView1) app.Route("^view2/$", simpleView2) app.Route("^view3/$", simpleView3) app.Route("^view4/(world)/$", simpleView4) app.Route("^view5/(world)/$", simpleView5) app.Route("^view6/(hello)/(world)/$", simpleView6) app.Route("^view7/$", simpleView7) app.Route("^view8/$", simpleView8) app.Route("^view9/$", simpleView9) app.Route("^notfound/$", notFoundView) app.Route("^redirect/$", redirectView) app.Route("^abort/$", abortView) app.Route("^noauth/$", noAuthView) app.Route("^panic/$", panicView) app.Route("^cookie/$", cookieView) app.Route("^cookie/set/$", cookieSet) app.Route("^cookie/delete/$", cookieDelete) app.Get("^method/$", func() string { return "get" }) app.Post("^method/$", func() string { return "post" }) app.Put("^method/$", func() string { return "put" }) app.Patch("^method/$", func() string { return "patch" }) app.Delete("^method/$", func() string { return "delete" }) app.Get("^method/get-only/$", func() string { return "get" }) app.Head("^head1/$", func() string { return "test head" }) app.Get("^head2/$", func() string { return "test get" }) app.Error(401, error401) subApp := uweb.NewApp() app.Mount("^sub/", subApp) subApp.Get("^view/$", simpleView1) }