Endpoint Configuration
Endpoint Configuration[edit]
An **endpoint** in Elixir refers to the interface for communication with external systems or services. In order to establish a connection and configure the behavior of your application's endpoints, you can use the `endpoint` configuration.
Configuration Options[edit]
The following configuration options are available for configuring an endpoint:
`http`[edit]
The `http` configuration option allows you to define the HTTP server that the endpoint will use. It supports the following settings:
- `port`: The port number the server will listen on (default: 4000).
- `ip`: The IP address that the server will bind to (default: "*").
- `handlers`: A list of functions that will be used as request handlers.
`url`[edit]
The `url` configuration option specifies the URL for the endpoint. It can contain placeholders that are replaced at runtime. The following placeholders are supported:
- `:scheme`: The protocol scheme.
- `:host`: The hostname.
- `:port`: The port number.
- `:path`: The path.
`cache_static_manifest`[edit]
The `cache_static_manifest` configuration option enables caching of static assets. It takes a boolean value (default: `false`).
`cache_static_manifest_path`[edit]
The `cache_static_manifest_path` configuration option specifies the path to the static asset manifest file. It is only used when `cache_static_manifest` is set to `true`.
`server`[edit]
The `server` configuration option allows you to specify the server to use for serving requests. It can be one of the following options:
- `:cowboy`: Uses the Cowboy server (default).
- `:pheonix`: Uses the Phoenix server.
Example Configuration[edit]
Here is an example of how to configure an endpoint in your `config.exs` file:
```elixir
config :my_app, MyApp.Endpoint, http: [port: 8080], url: [scheme: "http", host: "example.com", port: 8080], cache_static_manifest: true, cache_static_manifest_path: "priv/static/cache_manifest.json", server: :cowboy
```
For more information about endpoints and their configuration options, check the [Endpoint documentation](endpoint.md).