# `Skir.RPC.Service`
[🔗](https://github.com/gepheum/skir/blob/main/lib/skir/rpc/service.ex#L1)

In-process SkirRPC dispatcher.

`handle_request/3` accepts the raw SkirRPC payload used by both POST bodies and
decoded GET query strings, and returns a transport-neutral `RawResponse`.

# `handler`

```elixir
@type handler() :: (term(), term() -&gt;
                {:ok, term()}
                | {:error,
                   Skir.RPC.ServiceError.t() | Skir.RPC.UnknownError.t()})
```

# `t`

```elixir
@type t() :: %Skir.RPC.Service{
  by_number: term(),
  can_send_unknown_error_message: term(),
  error_logger: term(),
  keep_unrecognized_values: term(),
  max_request_bytes: term(),
  studio_app_js_url: term()
}
```

# `add_method`

```elixir
@spec add_method(t(), Skir.Method.t(), handler()) :: t()
```

Registers a method and an arity-2 handler receiving the decoded request and metadata. Duplicate method numbers raise `ArgumentError`.

# `handle_request`

```elixir
@spec handle_request(t(), binary(), term()) :: Skir.RPC.RawResponse.t()
```

Dispatches a raw SkirRPC payload, `list`, or `studio` and returns a `Skir.RPC.RawResponse`. Metadata is passed to the handler.

# `new`

```elixir
@spec new(keyword()) :: t()
```

Creates a service. Options configure unknown fields, error disclosure/logging, Studio, and request size.

# `set_can_send_unknown_error_message`

```elixir
@spec set_can_send_unknown_error_message(
  t(),
  boolean() | (Skir.RPC.ErrorInfo.t() -&gt; boolean())
) :: t()
```

Controls whether internal error messages reach clients, using a boolean or an `ErrorInfo` predicate. Default: hidden.

# `set_error_logger`

```elixir
@spec set_error_logger(t(), (Skir.RPC.ErrorInfo.t() -&gt; term())) :: t()
```

Sets the callback receiving `Skir.RPC.ErrorInfo` for controlled and unknown handler failures.

# `set_keep_unrecognized_values`

```elixir
@spec set_keep_unrecognized_values(t(), boolean()) :: t()
```

Controls preservation of unknown request fields.

# `set_max_request_bytes`

```elixir
@spec set_max_request_bytes(t(), pos_integer()) :: t()
```

Sets the maximum raw request size in bytes. The default is 4,194,304.

# `set_studio_app_js_url`

```elixir
@spec set_studio_app_js_url(t(), String.t()) :: t()
```

Sets the JavaScript URL loaded by the RPC Studio page.

---

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