# `PhoenixKit.Modules.Sitemap.RouteResolver`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.69/lib/modules/sitemap/route_resolver.ex#L1)

Resolves actual routes from parent application router.

Uses router introspection to automatically detect URL patterns,
falling back to Settings configuration when introspection fails.

## Resolution Priority

1. Router Introspection - automatic detection from parent app router
2. Settings override - manual configuration in PhoenixKit Settings
3. Hardcoded fallback - default values

## Usage

    # Find path for specific plug module
    RouteResolver.find_route(PhoenixKitWeb.Users.Registration)
    # => "/users/register"

    # Find content route by type
    RouteResolver.find_content_route(:pages)
    # => "/pages/:slug"

    RouteResolver.find_content_route(:entity, "product")
    # => "/products/:slug"

# `content_route_requires_auth?`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.69/lib/modules/sitemap/route_resolver.ex#L471)

```elixir
@spec content_route_requires_auth?(atom(), String.t() | nil) :: boolean()
```

Checks if a content route (posts, entities, etc.) requires authentication.

## Examples

    content_route_requires_auth?(:posts)
    # => false

    content_route_requires_auth?(:entity, "product")
    # => false

# `extract_prefix`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.69/lib/modules/sitemap/route_resolver.ex#L357)

```elixir
@spec extract_prefix(String.t() | nil) :: String.t() | nil
```

Extracts URL prefix from a route pattern.

## Examples

    extract_prefix("/pages/:slug")
    # => "/pages"

    extract_prefix("/content/*path")
    # => "/content"

    extract_prefix("/blog/posts/:id")
    # => "/blog/posts"

# `find_content_route`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.69/lib/modules/sitemap/route_resolver.ex#L200)

```elixir
@spec find_content_route(atom(), String.t() | nil) :: String.t() | nil
```

Finds route pattern by content type.

## Types

- `:pages` - Finds routes that look like page routes (contain :slug and plug name contains "page")
- `:posts` - Finds routes that look like post routes (contain :slug and plug name contains "post")
- `:entity` - Finds routes matching entity name (singular or plural form)

## Examples

    find_content_route(:pages)
    # => "/pages/:slug"

    find_content_route(:posts)
    # => "/posts/:slug"

    find_content_route(:entity, "product")
    # => "/products/:slug"

    find_content_route(:entity, "page")
    # => "/pages/:slug"

# `find_index_route`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.69/lib/modules/sitemap/route_resolver.ex#L280)

```elixir
@spec find_index_route(atom(), String.t() | nil) :: String.t() | nil
```

Finds index route for content type (list page without :slug).

## Examples

    find_index_route(:posts)
    # => "/posts"

    find_index_route(:entity, "page")
    # => "/page" or "/pages"

    find_index_route(:entity, "product")
    # => "/products"

# `find_route`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.69/lib/modules/sitemap/route_resolver.ex#L163)

```elixir
@spec find_route(
  module(),
  keyword()
) :: String.t() | nil
```

Finds path for a specific plug module.

## Options

- `:verb` - HTTP verb to match (default: `:get`)

## Examples

    find_route(PhoenixKitWeb.Users.Registration)
    # => "/users/register"

    find_route(MyApp.SomeController, verb: :post)
    # => "/some/path"

# `get_router`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.69/lib/modules/sitemap/route_resolver.ex#L38)

Gets router module with automatic discovery.

Resolution order:
1. `config :phoenix_kit, router: MyAppWeb.Router`
2. Via endpoint from `config :phoenix_kit, endpoint: MyAppWeb.Endpoint`
3. Auto-discover from OTP applications (finds *Web.Router modules)

# `get_routes`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.69/lib/modules/sitemap/route_resolver.ex#L131)

```elixir
@spec get_routes() :: [map()]
```

Returns all routes from the parent router.

Returns empty list if router is not available.

# `route_requires_auth?`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.69/lib/modules/sitemap/route_resolver.ex#L435)

```elixir
@spec route_requires_auth?(map() | String.t()) :: boolean()
```

Checks if a route requires authentication based on its on_mount hooks.

Returns true if the route uses authentication-requiring on_mount hooks:
- `:phoenix_kit_ensure_authenticated_scope`
- `:phoenix_kit_ensure_admin`

## Examples

    route_requires_auth?(%{metadata: %{...}})
    # => true/false

    # Check by path pattern
    route_requires_auth?("/posts")
    # => true/false

---

*Consult [api-reference.md](api-reference.md) for complete listing*
