|
|
|
|
|
by optymizer1
4530 days ago
|
|
You could even go further and assume all user resources are logical extensions of sleepy.Resource: type HelloResource struct {
sleepy.Resource
}
This makes it clear that you're inheriting everything from sleepy.Resource, so you can provide reasonable implementations for all methods of resources, not just HTTP methods handlers, e.g. getBodyAsJSON(), redirect(resource), etc.Also, depending on how your mux works, you could store app-level data in sleepy.Resource, to be accessed by all resources: sleepy.Resource.DB
sleepy.Resource.Session
sleepy.Resource.Root
and other things I can't think of right now. |
|