canceraiddev / elm-pages / ApiRoute

ApiRoute's are defined in src/Api.elm and are a way to generate files, like RSS feeds, sitemaps, or any text-based file that you output with an Elm function! You get access to a DataSource so you can pull in HTTP data, etc. Because ApiRoutes don't hydrate into Elm apps (like pages in elm-pages do), you can pull in as much data as you want in the DataSource for your ApiRoutes, and it won't effect the payload size. Instead, the size of an ApiRoute is just the content you output for that route.

In a future release, ApiRoutes may be able to run at request-time in a serverless function, allowing you to use pure Elm code to create dynamic APIs, and even pulling in data from DataSources dynamically.


type alias ApiRoute response =
Internal.ApiRoute response


type alias ApiRouteBuilder a constructor =
Internal.ApiRouteBuilder a constructor


type alias Response =
{ body : String }

buildTimeRoutes : (constructor -> DataSource (List (List String))) -> ApiRouteBuilder (DataSource Response) constructor -> ApiRoute Response

capture : ApiRouteBuilder (String -> a) constructor -> ApiRouteBuilder a (String -> constructor)

int : ApiRouteBuilder (Basics.Int -> a) constructor -> ApiRouteBuilder a (Basics.Int -> constructor)

literal : String -> ApiRouteBuilder a constructor -> ApiRouteBuilder a constructor

single : ApiRouteBuilder (DataSource Response) (List String) -> ApiRoute Response

slash : ApiRouteBuilder a constructor -> ApiRouteBuilder a constructor

succeed : a -> ApiRouteBuilder a (List String)

getBuildTimeRoutes : ApiRoute response -> DataSource (List String)

For internal use by generated code. Not so useful in user-land.