Routing

Slide Routing examples

Routing

app := slide.InitServer(&config)
app.Get("/", func(ctx *slide.Ctx) error {
	return ctx.Send(http.StatusOK, "Hello, World")
})
app.Post("/", func(ctx *slide.Ctx) error {
	return ctx.Send(http.StatusOK, "Hello, World")
})
app.Put("/", func(ctx *slide.Ctx) error {
	return ctx.Send(http.StatusOK, "Hello, World")
})
app.Delete("/", func(ctx *slide.Ctx) error {
	return ctx.Send(http.StatusOK, "Hello, World")
})

Grouping

Slide Supports grouping your routes

auth := app.Group("/auth")
// this becomes /auth/login
auth.Get("/login", func(ctx *slide.Ctx) error {
	return ctx.Send(http.StatusOK, "Hello, World")
})

Path Param

For all wild card path param we use following regex

Query Param

Redirect

Custom Routes

404 Handler

Error Handler

Last updated

Was this helpful?