Later we'll see when you would use a different type here. The argument to withListing is the identifier for the type of listing, corresponding to the type The listing will beĪvailable on the path /post, and the individual items on paths like /post/title/. We define a top level listing, and a way to get a single post by title. It defines the routes that are available on this resource. The 'name' field just sets the string that will be used for this resource in urls. Module Api.Post ( resource ) where import Rest import qualified Rest.Resource as R type Title = String resource :: Resource IO ( ReaderT Title IO ) Title () Void resource = mkResourceReader The context for subhandlers, to contain the Title of the post using ReaderT Title IO. We don't do anything special, we'll have the first one be IO. Which one you useĭepends on what the types m and s are in your resource. Smart constructors: mkResourceId, mkResourceReader and mkResourceReaderWith. The easiest way to create a resource is using one of the One for a single item, one for listings, and one for top-level actions. The last three type parameters are identifiers for this resource: It can be used to pass data to subresources. You get after a single resource has been identified. The first represents the context you get from your parent resource. The first two type parameters represent the context that the handlers for this resource will run in.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |