2020-07-08 21:59:37 -04:00
|
|
|
package rest
|
|
|
|
|
|
|
|
import (
|
|
|
|
gohttp "net/http"
|
|
|
|
|
|
|
|
"github.com/jchenry/x/net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
// EntityHandler returns a handler that provides restful verbs, following a CRUD model
|
2020-08-22 20:00:38 -04:00
|
|
|
func restVerbHandler(
|
2020-07-08 21:59:37 -04:00
|
|
|
get gohttp.Handler,
|
|
|
|
post gohttp.Handler,
|
|
|
|
put gohttp.Handler,
|
|
|
|
delete gohttp.Handler,
|
|
|
|
) gohttp.HandlerFunc {
|
|
|
|
h, _ := http.MutliHandler(map[string]gohttp.Handler{
|
|
|
|
gohttp.MethodGet: get,
|
|
|
|
gohttp.MethodPost: post,
|
|
|
|
gohttp.MethodPut: put,
|
|
|
|
gohttp.MethodDelete: delete,
|
|
|
|
})
|
|
|
|
return h
|
|
|
|
}
|