_examples/todos-resource/todos.go
func (rs todosResource) Routes() chi.Router {
	r := chi.NewRouter()
	// r.Use() // some middleware..

	r.Get("/", rs.List)    // GET /todos - read a list of todos
	r.Post("/", rs.Create) // POST /todos - create a new todo and persist it
	r.Put("/", rs.Delete)

	r.Route("/{id}", func(r chi.Router) {
		// r.Use(rs.TodoCtx) // lets have a todos map, and lets actually load/manipulate
		r.Get("/", rs.Get)       // GET /todos/{id} - read a single todo by :id
		r.Put("/", rs.Update)    // PUT /todos/{id} - update a single todo by :id
		r.Delete("/", rs.Delete) // DELETE /todos/{id} - delete a single todo by :id
		r.Get("/sync", rs.Sync)
	})

	return r
}
func (rs todosResource) Routes() chi.Router {
	r := chi.NewRouter()
	// r.Use() // some middleware..

	r.Get("/", rs.List)    // GET /todos - read a list of todos
	r.Post("/", rs.Create) // POST /todos - create a new todo and persist it
	r.Put("/", rs.Delete)

	r.Route("/{id}", func(r chi.Router) {
		// r.Use(rs.TodoCtx) // lets have a todos map, and lets actually load/manipulate
		r.Get("/", rs.Get)       // GET /todos/{id} - read a single todo by :id
		r.Put("/", rs.Update)    // PUT /todos/{id} - update a single todo by :id
		r.Delete("/", rs.Delete) // DELETE /todos/{id} - delete a single todo by :id
		r.Get("/sync", rs.Sync)
	})

	return r
}
func ( rs todosResource ) Routes ( ) chi . Router { r := chi . NewRouter ( ) // r.Use() // some middleware.. r . Get ( " " , rs . List ) // GET /todos - read a list of todos r . Post ( " " , rs . Create ) // POST /todos - create a new todo and persist it r . Put ( " " , rs . Delete ) r . Route ( " " , func ( r chi . Router ) { // r.Use(rs.TodoCtx) // lets have a todos map, and lets actually load/manipulate r . Get ( " " , rs . Get ) // GET /todos/{id} - read a single todo by :id r . Put ( " " , rs . Update ) // PUT /todos/{id} - update a single todo by :id r . Delete ( " " , rs . Delete ) // DELETE /todos/{id} - delete a single todo by :id r . Get ( " " , rs . Sync ) } ) return r }
// Routes creates a REST router for the todos resource
Routes creates a REST router for the todos resource