Closed tylermmorton closed 3 months ago
In the current version of the torque API, Loader and Renderer simply use the any type to describe the loader data.
torque
Loader
Renderer
any
type Loader interface { Load(req *http.Request) (any, error) } type Renderer interface { Render(wr http.ResponseWriter, req *http.Request, loaderData any) error }
It would be great for API ergonomics to be able to declare them using a generic combination interface:
Illustration:
type GenericRenderer[T any] interface { Load(req *http.Request) (T, error) Render(wr http.ResponseWriter, req *http.Request, loaderData T) error }
Rough outline of solution:
handleLoader
handleRenderer
In the current version of the
torque
API,Loader
andRenderer
simply use theany
type to describe the loader data.It would be great for API ergonomics to be able to declare them using a generic combination interface:
Illustration:
Rough outline of solution:
handleLoader
andhandleRenderer
in server.go to support the new interface type. This may or may not be possible with the generic type.