struct Amber::Router::ParamConstraints::Slug

Overview

Matches a lowercase slug: runs of a-z and 0-9 joined by single hyphens, such as my-post-123. A slug never starts or ends with a hyphen and never has two in a row.

Included Modules

Defined in:

amber/router/param_constraints/slug.cr

Constructors

Instance Method Summary

Instance methods inherited from module Amber::Router::ParamConstraint

matches?(segment : String) : Bool matches?, matches_span?(path : String, byte_offset : Int32, bytesize : Int32) : Bool matches_span?, to_s(io : IO) : Nil to_s

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def initialize #

[View source]
def matches?(segment : String) : Bool #
Description copied from module Amber::Router::ParamConstraint

Returns true when segment satisfies this rule.


[View source]
def matches_span?(path : String, byte_offset : Int32, bytesize : Int32) : Bool #
Description copied from module Amber::Router::ParamConstraint

Returns true when the segment of path that starts at byte_offset and is bytesize bytes long satisfies this rule. The router calls this while it walks a path; the built-in rules override it to read the bytes in place instead of copying the segment.


[View source]
def to_s(io : IO) : Nil #
Description copied from module Amber::Router::ParamConstraint

Writes the short label that route listings and Route#to_json show for this rule.


[View source]