Closed tmcgilchrist closed 9 years ago
Great question.
It doesn't seem like you'd want either of them to dynamic or perhaps I'm missing a use-case where you do.
Allowing them to be dynamic was exactly the rationale for putting them in this monad. For a trivial example, see the contentTypesProvided implementation of the static file resources. This needs to first look up the content-type from the 'state', before returning what content type is allowed on that particular path.
Another use-case would be implementing a CMS (content management system) where the entire application is database-driven.
Another example: imagine writing a resource where POST
is only allowed the day that some new concert tickets are available.
Thanks for the examples, makes sense.
This is more a query about the types of
allowedMethods
,contentTypesAccepted
[1] and possiblycontentTypesProvided
. At the moment each of them is wrapped in aHandler s m a
. I'm wondering why they can't just be sayBool
or[(MediaType, Handler s m ())]
. It doesn't seem like you'd want either of them to dynamic or perhaps I'm missing a use-case where you do.We are thinking if they're not wrapped in
Handler s m a
we could generate nice API docs from each of the resources.[1]https://github.com/helium/airship/blob/master/src/Airship/Resource.hs#L37-L46