Skip to content

Commit

Permalink
Link to ApplicationState's in-depth guide from the project structure …
Browse files Browse the repository at this point in the history
…section.
  • Loading branch information
LukeMathWalker committed Mar 30, 2024
1 parent a267dc7 commit 0f282c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# `ApplicationState`

All the [`Singleton`][Lifecycle::Singleton] types that your application needs to access at runtime
when processing a request are grouped together in a struct called [`ApplicationState`][ApplicationState].
The [`ApplicationState`][ApplicationState] is code-generated by Pavex:
you don't have to write it yourself!
when processing a request are grouped together in a struct called `ApplicationState`.
The `ApplicationState` is code-generated by Pavex: you don't have to write it yourself!

It is defined in the [server SDK crate] and exported as a public type.
It is then used in the [server crate] as an input parameter
Expand Down
15 changes: 8 additions & 7 deletions docs/guide/project_structure/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,23 @@ It's right there in your filesystem: you can open it, you can read it, you can u
to get a deeper understanding of how Pavex works under the hood.

At the same time, you actually don't need to know how it works to use it.
As a Pavex user, **you only need to care about** the two public types it exports: **the `run` function and the `ApplicationState`
As a Pavex user, **you only need to care about** the two public types it exports: **the `run` function and the [`ApplicationState`](#applicationstate)
struct**.

### `ApplicationState`

`ApplicationState` holds all the types with a [`Singleton` lifecycle][Lifecycle::Singleton]
that your application needs to access at runtime when processing a request.
[`ApplicationState`](../dependency_injection/core_concepts/application_state.md) holds all the types
with a [`Singleton` lifecycle][Lifecycle::Singleton] that your application needs to access at runtime when processing a request.

To build an instance of `ApplicationState`, the server SDK exposes a function called `build_application_state`.
To build an instance of [`ApplicationState`](../dependency_injection/core_concepts/application_state.md),
the server SDK exposes a function called `build_application_state`.

### `run`

`run` is the entrypoint of your application.
It takes as input:

- an instance of `ApplicationState`
- an instance of [`ApplicationState`](#applicationstate)
- a [`pavex::server::Server`][Server] instance

[`pavex::server::Server`][Server] holds the configuration for the HTTP server that will be used to serve your API:
Expand Down Expand Up @@ -157,7 +158,7 @@ That's why you need a **server crate**.
### The executable binary

The server crate contains the `main` function that you'll be running to start your application.
In that `main` function you'll be building an instance of `ApplicationState` and passing it to `run`.
In that `main` function you'll be building an instance of [`ApplicationState`](#applicationstate) and passing it to `run`.
You'll be doing a few other things too: initializing your `tracing` subscriber, loading
configuration, etc.

Expand Down Expand Up @@ -188,4 +189,4 @@ The `demo` project includes an example of such a test which you can use as a ref
[middlewares]: ../middleware/index.md
[error handlers]: ../errors/error_handlers.md
[error observers]: ../errors/error_observers.md
[cargo-px]: https://github.com/LukeMathWalker/cargo-px
[cargo-px]: https://github.com/LukeMathWalker/cargo-px

0 comments on commit 0f282c0

Please sign in to comment.