<commit_before>"""
  Router is the root of the tree
"""
type Router
    root::Endpoint
end

"""
  parseurl should change
"""
parseurl(str) = filter(split(str, '/')) do str
    str != ""
end


macro field(typ, attr)
    typeof(typ) != Symbol && error("First argument must be a symbol")
    Expr(:., (esc(typ)), :($attr))
end

"""
  not working
"""
todict(t) = (sym::Symbol) -> (Expr(:., :r, :($sym)))

"""
    todict converts any type passed and returns a dict
"""
function todict(typ)
    output = Dict()
    for field in fieldnames(typ)
        output[field] = @field typ field
    end
    output
end

todict(t...) = map(todict, t...)

"""
# Mount
takes one routing tree `r2` and attaches it to another routing tree `r1`
the mount will applied according to the specified path `to`

return returns the leaf node
"""
function mount!(r1::Router, r2::Router; to="/")
    root = buildtree(to; root=StaticEndpoint("/"))
    tokens = parseurl(to)<commit_msg>fixed the todict function<commit_after>"""
  Router is the root of the tree
"""
type Router
    root::Endpoint
end

"""
  parseurl should change
"""
parseurl(str) = filter(split(str, '/')) do str
    str != ""
end

"""
"""
macro field(typ, attr)
    typeof(typ) != Symbol && error("First argument must be a symbol")
    if typeof(attr) == Symbol
        Expr(:., (esc(typ)), :($attr))
    else
        Expr(:., (esc(typ)), :($(esc(attr))))
    end
end

"""
    todict converts any type passed and returns a dict
"""
function todict(typ)
    output = Dict()
    for field in fieldnames(typ)
        output[field] = @field typ field
    end
    output
end

todict(t...) = map(todict, t)

"""
# Mount
takes one routing tree `r2` and attaches it to another routing tree `r1`
the mount will applied according to the specified path `to`

return returns the leaf node
"""
function mount!(r1::Router, r2::Router; to="/")
    root = buildtree(to; root=StaticEndpoint("/"))
    tokens = parseurl(to)
{'fraction_non_alphanumeric': 0.15816589386913962, 'fraction_numerical': 0.004121586810922205, 'mean_word_length': 3.4541284403669725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '861009', 'n_tokens_mistral': 643, 'n_tokens_neox': 629, 'n_words': 219}