Yoga.HTTP.API.Path
- Package
- purescript-yoga-http-api
- Repository
- rowtype-yoga/purescript-yoga-http-api
#Path Source
data Path :: forall k. k -> Typedata Path segments
Type-level path representation
Examples: Path Root -- / Path (Lit "users") -- /users Path (Lit "users" / Capture "id" Int) -- /users/:id Path (Lit "users" / Capture "id" Int / Lit "posts") -- /users/:id/posts
Instances
(PathPatternSegs segs) => PathPattern (Path segs)(PathPatternSegs segs) => PathPatternSegs (Path segs)ParsePath (Path Root) ()(IsSymbol s) => ParsePath (Path (Lit s)) ()(IsSymbol name, ParseParam ty) => ParsePath (Path (Capture name ty)) (name :: ty)(IsSymbol s, ParsePath (Path rest) params) => ParsePath (Path (PathCons (Lit s) rest)) params(IsSymbol name, ParseParam ty, ParsePath (Path rest) restParams, Cons name ty restParams fullParams, Lacks name restParams) => ParsePath (Path (PathCons (Capture name ty) rest)) fullParams
#Lit Source
data Lit :: Symbol -> Typedata Lit (segment :: Symbol)
Literal path segment (wrapper for Symbol to work around PureScript 0.15 limitations)
In PureScript 0.15, we can't use bare Symbols like Path "users" due to kind inference. Instead, use: Path (Lit "users")
Example: Path (Lit "users") -- /users Path (Lit "users" / Capture "id" Int) -- /users/:id
Instances
#Capture Source
data Capture :: Symbol -> Type -> Typedata Capture (name :: Symbol) (ty :: Type)
Capture a path parameter with a name and type
Example: Capture "id" Int -- captures :id as an Int Capture "name" String -- captures :name as a String
Instances
(IsSymbol name) => PathPatternSegs (Capture name ty)(IsSymbol name, PathPatternSegs rest) => PathPatternSegs (PathCons (Capture name ty) rest)(IsSymbol name, ParseParam ty) => ParsePath (Path (Capture name ty)) (name :: ty)(IsSymbol name, ParseParam ty, ParsePath (Path rest) restParams, Cons name ty restParams fullParams, Lacks name restParams) => ParsePath (Path (PathCons (Capture name ty) rest)) fullParams
#PathCons Source
data PathCons :: forall k1 k2. k1 -> k2 -> Typedata PathCons left right
Instances
(IsSymbol s, PathPatternSegs rest) => PathPatternSegs (PathCons (Lit s) rest)(IsSymbol name, PathPatternSegs rest) => PathPatternSegs (PathCons (Capture name ty) rest)(IsSymbol name, PathPatternSegs rest) => PathPatternSegs (PathCons (Param name ty) rest)(IsSymbol s, PathPatternSegs rest) => PathPatternSegs (PathCons s rest)(IsSymbol s, ParsePath (Path rest) params) => ParsePath (Path (PathCons (Lit s) rest)) params(IsSymbol name, ParseParam ty, ParsePath (Path rest) restParams, Cons name ty restParams fullParams, Lacks name restParams) => ParsePath (Path (PathCons (Capture name ty) rest)) fullParams
#type (/) Source
Operator alias for Yoga.HTTP.API.Path.PathCons (right-associative / precedence 6)
Infix operator for building paths
Example: Lit "users" / Capture "id" Int / Lit "posts"
#Param Source
data Param :: Symbol -> Type -> Typedata Param (name :: Symbol) (ty :: Type)
Sugar for Capture — use with bare Symbols in the path DSL
Example: Path ("users" / "id" : Int / "posts") -- equivalent to: Path (Lit "users" / Capture "id" Int / Lit "posts")
Instances
(IsSymbol name) => PathPatternSegs (Param name ty)(IsSymbol name, PathPatternSegs rest) => PathPatternSegs (PathCons (Param name ty) rest)
#QueryParams Source
data QueryParams :: forall k. k -> Type -> Typedata QueryParams path params
Attach query parameters to a path
Example: Path ("users" / "id" : Int) :? { limit :: Int, offset :: Required Int }
Instances
(PathPattern path) => PathPattern (QueryParams path params)
#type (:?) Source
Operator alias for Yoga.HTTP.API.Path.QueryParams (left-associative / precedence 1)
#Required Source
data Required aMarker for required query parameters (default is optional → Maybe)
Example: Path ("users") :? (limit :: Int, offset :: Required Int) -- limit parses as Maybe Int, offset parses as Int (fails if missing)
#PathPattern Source
class PathPattern :: forall k. k -> Constraintclass PathPattern path where
Generate a Fastify-compatible URL pattern from a path type
Examples: pathPattern (Proxy :: _ (Path Root)) = "/" pathPattern (Proxy :: _ (Path (Lit "users"))) = "/users" pathPattern (Proxy :: _ (Path (Lit "users" / Capture "id" Int))) = "/users/:id" pathPattern (Proxy :: _ ("users" / "id" : Int)) = "/users/:id"
Members
pathPattern :: Proxy path -> String
Instances
(PathPattern path) => PathPattern (QueryParams path params)(PathPatternSegs segs) => PathPattern (Path segs)(PathPatternSegs segs) => PathPattern segs
#PathPatternSegs Source
class PathPatternSegs :: forall k. k -> Constraintclass PathPatternSegs segs where
Internal poly-kinded class for generating URL patterns from path segments.
Members
pathPatternSegs :: Proxy segs -> String
Instances
PathPatternSegs RootPathPatternSegs "/"(IsSymbol s) => PathPatternSegs (Lit s)(IsSymbol name) => PathPatternSegs (Capture name ty)(IsSymbol name) => PathPatternSegs (Param name ty)(IsSymbol s, PathPatternSegs rest) => PathPatternSegs (PathCons (Lit s) rest)(IsSymbol name, PathPatternSegs rest) => PathPatternSegs (PathCons (Capture name ty) rest)(IsSymbol name, PathPatternSegs rest) => PathPatternSegs (PathCons (Param name ty) rest)(IsSymbol s, PathPatternSegs rest) => PathPatternSegs (PathCons s rest)(PathPatternSegs segs) => PathPatternSegs (Path segs)(IsSymbol s) => PathPatternSegs s
#ParseParam Source
class ParseParam (ty :: Type) whereParse a value from a String (used for path captures)
Members
parseParam :: String -> Either String ty
Instances
#ParsePath Source
class ParsePath :: Type -> Row Type -> Constraintclass ParsePath (path :: Type) (params :: Row Type) | path -> params where
Parse a URL string into a record of typed path parameters
Examples: parsePath @(Path Root) "/" = Just {} parsePath @(Path (Lit "users")) "/users" = Just {} parsePath @(Path (Lit "users" / Capture "id" Int)) "/users/123" = Just { id: 123 }
Members
Instances
ParsePath (Path Root) ()(IsSymbol s) => ParsePath (Path (Lit s)) ()(IsSymbol name, ParseParam ty) => ParsePath (Path (Capture name ty)) (name :: ty)(IsSymbol s, ParsePath (Path rest) params) => ParsePath (Path (PathCons (Lit s) rest)) params(IsSymbol name, ParseParam ty, ParsePath (Path rest) restParams, Cons name ty restParams fullParams, Lacks name restParams) => ParsePath (Path (PathCons (Capture name ty) rest)) fullParams
- Modules
- Yoga.
HTTP. API. Path - Yoga.
HTTP. API. Route - Yoga.
HTTP. API. Route. Auth - Yoga.
HTTP. API. Route. BearerToken - Yoga.
HTTP. API. Route. Encoding - Yoga.
HTTP. API. Route. Handler - Yoga.
HTTP. API. Route. HeaderError - Yoga.
HTTP. API. Route. HeaderValue - Yoga.
HTTP. API. Route. Method - Yoga.
HTTP. API. Route. OpenAPI - Yoga.
HTTP. API. Route. OpenAPIMetadata - Yoga.
HTTP. API. Route. RenderMethod - Yoga.
HTTP. API. Route. Response - Yoga.
HTTP. API. Route. Route - Yoga.
HTTP. API. Route. RouteHandler - Yoga.
HTTP. API. Route. StatusCode