diff --git a/log/logger.go b/log/logger.go index 4a63899..42e307a 100644 --- a/log/logger.go +++ b/log/logger.go @@ -1,7 +1,7 @@ package log // Logger is a logging interface with only the essentials that a function that needs to log should care about. Compatible with standard Go logger. -type Logger interface { +type Interface interface { Fatal(v ...any) Fatalf(format string, v ...any) Fatalln(v ...any) diff --git a/rest/collection.go b/rest/collection.go index eadb884..a4d9682 100755 --- a/rest/collection.go +++ b/rest/collection.go @@ -11,7 +11,7 @@ import ( ) // Example: Resource(p, c, JSONEncoder, json.Decode(func()interface{}{return &foo{}}), log.None{}) -func Resource(p *sync.Pool, g Gateway, e EntityEncoder, d encoding.Decoder, l log.Logger) http.HandlerFunc { +func Resource(p *sync.Pool, g Gateway, e EntityEncoder, d encoding.Decoder, l log.Interface) http.HandlerFunc { return restVerbHandler( GetResource(g, e, l), PostResource(g, d, p, l), @@ -20,7 +20,7 @@ func Resource(p *sync.Pool, g Gateway, e EntityEncoder, d encoding.Decoder, l lo ) } -func GetResource(store Readable, encode EntityEncoder, log log.Logger) http.HandlerFunc { +func GetResource(store Readable, encode EntityEncoder, log log.Interface) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // GET if id := filepath.Base(r.URL.Path); id != "" { if e, err := store.Read(id); err == nil { // handle individual entity @@ -44,7 +44,7 @@ func GetResource(store Readable, encode EntityEncoder, log log.Logger) http.Hand } } -func PostResource(store Creatable, decode encoding.Decoder, pool *sync.Pool, log log.Logger) http.HandlerFunc { +func PostResource(store Creatable, decode encoding.Decoder, pool *sync.Pool, log log.Interface) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // POST TODO e := pool.Get() defer pool.Put(e) @@ -61,7 +61,7 @@ func PostResource(store Creatable, decode encoding.Decoder, pool *sync.Pool, log } } -func PutResource(store Updatable, encode EntityEncoder, decode encoding.Decoder, pool *sync.Pool, log log.Logger) http.HandlerFunc { +func PutResource(store Updatable, encode EntityEncoder, decode encoding.Decoder, pool *sync.Pool, log log.Interface) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // PUT TODO e := pool.Get() defer pool.Put(e) @@ -79,7 +79,7 @@ func PutResource(store Updatable, encode EntityEncoder, decode encoding.Decoder, } } -func DeleteResource(store Deletable, log log.Logger) http.HandlerFunc { +func DeleteResource(store Deletable, log log.Interface) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // DELETE TODO if id := filepath.Base(r.URL.Path); id != "" { if err := store.Delete(id); err == nil {