yesod-raml: RAML style route definitions for Yesod

[ library, mit, web, yesod ] [ Propose Tags ]

RAML style route definitions for Yesod


[Skip to Readme]

Flags

Automatic Flags
NameDescriptionDefault
utils

Build utility programs

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.2.0
Change log ChangeLog.md
Dependencies aeson, base (>=4 && <5), bytestring, containers, network-uri, optparse-applicative, regex-posix, template-haskell, text, unordered-containers, yaml, yesod-core, yesod-raml [details]
License MIT
Author Junji Hashimoto
Maintainer junji.hashimoto@gmail.com
Category Web, Yesod
Uploaded by junjihashimoto at 2015-05-24T15:21:53Z
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Executables raml-utils
Downloads 3489 total (15 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-05-26 [all 1 reports]

Readme for yesod-raml-0.1.0

[back to package description]

Yesod-Raml:

Hackage version Build Status

Yesod-Raml makes routes definition from RAML File.

raml style routes definition is inspired by sbt-play-raml.

Getting started

Install this from Hackage.

cabal update && cabal install yesod-raml

Usage

Use parseRamlRoutes or parseRamlRoutesFile in instead of parseRoutes or parseRoutesFile.

Write RAML with handler-tag for Yesod Handler.

handler-tag is not a tag of RAML spec but original one.

You can use description-tag with handler: <<handler-name>> instead of handler-tag.

Bracket variable(PathPiece) like {hogehoge} is capitalized. The variable becomes #Hogehoge. because variable(PathPiece) of yesod-routes is data-type like String or Text.

Examples are below.

type Userid = String

mkYesod "App" [parseRamlRoutes|
#%RAML 0.8
title: Hoge API
baseUri: 'https://hoge/api/{version}'
version: v1
protocols: [ HTTPS ]
/user:
  /{userid}:
# handler tag is used.
    handler: HogeR
    get:
      description: Get user list
    /del:
# handler is written in description-tag
      description: |
	    handler: Hoge2R
      post:
        description: Delete user
|]

This is the same as following codes.

As you can see, {userid} becomes #Userid.

type Userid = String

mkYesod "App" [parseRoutes|
/user/#Userid HogeR GET
/user/#Userid/del Hoge2R POST
|]