howdy/url_parser

Handles matching of router template to the incoming request route

Types

Error return types for parsing URL segments

pub type SegmentError {
  NonMatchingUrl
}

Constructors

  • NonMatchingUrl

    None matching URL

Matching segment types

pub type UrlSegment {
  MatchingSegment(lhs: String, rhs: String)
  MatchingTemplateTypedSegment(
    lhs: String,
    rhs: String,
    name: String,
    value: dynamic.Dynamic,
  )
  WildcardSegment(lhs: String, rhs: String, wilcard_path: String)
  NonMatchingSegment
}

Constructors

  • MatchingSegment(lhs: String, rhs: String)

    Set when the template segment matches the request segment

  • MatchingTemplateTypedSegment(
      lhs: String,
      rhs: String,
      name: String,
      value: dynamic.Dynamic,
    )

    Sets a template segemnt if the URL matches the templated segment

  • WildcardSegment(lhs: String, rhs: String, wilcard_path: String)

    Sets the wildcard segment if the template ends with a ‘*’

    Example

    WildcardSegment(lhs: "/blog/*", rhs: "/blog/page1/content", wildcard_path: "page1/content")
    
  • NonMatchingSegment

    Sets a non matching segment, this means that the Url from the request no longer matches the template url, and forces the parse to stop parsing the remaining url segments and retur an Error

Functions

pub fn parse(template: String, path: String) -> Result(
  List(UrlSegment),
  SegmentError,
)

parses the route template and the request path into a list of UrlSegments