golazy.dev
–
golazy.dev
/
lazyroutes
Index
|
Files
package lazyroutes
import "golazy.dev/lazyroutes"
Functions
func Bind[T any]
func Bind[T any](
ctx context.Context,
factory Factory[T],
action func(*T, http.ResponseWriter, *http.Request) error,
) http.Handler
func Handle
func Handle(action Action) http.Handler
func MethodNotAllowed
func MethodNotAllowed(allowed ...string) http.Handler
func New
func New(ctx context.Context) *http.ServeMux
func WithPublic
func WithPublic(ctx context.Context, public http.Handler) context.Context
Types
type Action
type Action func(http.ResponseWriter, *http.Request) error
type Factory
type Factory[T any] func(context.Context) (*T, error)
type Resource
type Resource[T any] struct {
// contains filtered or unexported fields
}
func Resources[T any]
func Resources[T any](
ctx context.Context,
mux *http.ServeMux,
factory Factory[T],
configure ...func(*Resource[T]),
) *Resource[T]
func (r *Resource[T]) Delete
func (r *Resource[T]) Delete(path string, action func(*T, http.ResponseWriter, *http.Request) error)
func (r *Resource[T]) Get
func (r *Resource[T]) Get(path string, action func(*T, http.ResponseWriter, *http.Request) error)
func (r *Resource[T]) MemberDelete
func (r *Resource[T]) MemberDelete(path string, action func(*T, http.ResponseWriter, *http.Request) error)
func (r *Resource[T]) MemberGet
func (r *Resource[T]) MemberGet(path string, action func(*T, http.ResponseWriter, *http.Request) error)
func (r *Resource[T]) MemberPatch
func (r *Resource[T]) MemberPatch(path string, action func(*T, http.ResponseWriter, *http.Request) error)
func (r *Resource[T]) MemberPost
func (r *Resource[T]) MemberPost(path string, action func(*T, http.ResponseWriter, *http.Request) error)
func (r *Resource[T]) MemberPut
func (r *Resource[T]) MemberPut(path string, action func(*T, http.ResponseWriter, *http.Request) error)
func (r *Resource[T]) Param
func (r *Resource[T]) Param(name string) *Resource[T]
func (r *Resource[T]) Patch
func (r *Resource[T]) Patch(path string, action func(*T, http.ResponseWriter, *http.Request) error)
func (r *Resource[T]) Path
func (r *Resource[T]) Path(path string) *Resource[T]
func (r *Resource[T]) Plural
func (r *Resource[T]) Plural(name string) *Resource[T]
func (r *Resource[T]) Post
func (r *Resource[T]) Post(path string, action func(*T, http.ResponseWriter, *http.Request) error)
func (r *Resource[T]) Put
func (r *Resource[T]) Put(path string, action func(*T, http.ResponseWriter, *http.Request) error)
func (r *Resource[T]) Singular
func (r *Resource[T]) Singular(name string) *Resource[T]