Skip to content

Commit

Permalink
Merge branch 'master' into fix-migration-order
Browse files Browse the repository at this point in the history
  • Loading branch information
jondot authored Nov 5, 2024
2 parents 9bda013 + b6ad606 commit 248e51c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

## Unreleased

* `loco doctor` now checks for app-specific minimum dependency versions. This should help in upgrades. `doctor` also supports "production only" checks which you can run in production with `loco doctor --production`. This, for example, will check your connections but will not check dependencies.
*
* `loco doctor` now checks for app-specific minimum dependency versions. This should help in upgrades. `doctor` also supports "production only" checks which you can run in production with `loco doctor --production`. This, for example, will check your connections but will not check dependencies. [https://github.com/loco-rs/loco/pull/931](https://github.com/loco-rs/loco/pull/931)
* Use a single loco-rs dep for a whole project. [https://github.com/loco-rs/loco/pull/927](https://github.com/loco-rs/loco/pull/927)
* chore: fix generated testcase. [https://github.com/loco-rs/loco/pull/939](https://github.com/loco-rs/loco/pull/939)
* chore: Correct cargo test message. [https://github.com/loco-rs/loco/pull/938](https://github.com/loco-rs/loco/pull/938)
* Add relevant meta tags for better defaults. [https://github.com/loco-rs/loco/pull/943](https://github.com/loco-rs/loco/pull/943)
* Update cli message with correct command. [https://github.com/loco-rs/loco/pull/942](https://github.com/loco-rs/loco/pull/942)
* remove lazy_static. [https://github.com/loco-rs/loco/pull/941](https://github.com/loco-rs/loco/pull/941)
* change update HTTP verb semantics to put+patch. [https://github.com/loco-rs/loco/pull/919](https://github.com/loco-rs/loco/pull/919)
* Fixed HTML scaffold error. [https://github.com/loco-rs/loco/pull/960](https://github.com/loco-rs/loco/pull/960)
* Scaffolded HTML update method should be POST. [https://github.com/loco-rs/loco/pull/963](https://github.com/loco-rs/loco/pull/963)

## v0.12.0

Expand Down
14 changes: 7 additions & 7 deletions docs-site/content/docs/extras/pluggability.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ logger:

The most important knobs here are:

* `level` - your standard logging levels. Typically `debug` or `trace` in development. In production choose what you are used to.
* `pretty_backtrace` - provides clear, concise path to the line of code causing the error. use `true` in development and turn off in production. In cases where you are debugging things in production and need some extra hand, you can turn it on and then off when you're done.
* `level` - your standard logging levels. Typically `debug` or `trace` in development. In production, choose what you are used to.
* `pretty_backtrace` - provides a clear, concise path to the line of code causing the error. Use `true` in development and turn it off in production. In cases where you are debugging things in production and need some extra hand, you can turn it on and then off when you're done.

### Controller logging

Expand Down Expand Up @@ -92,7 +92,7 @@ Usually you can expect the following from errors:
Notes:

* An _error chain_ was experimented with, but provides little value in practice.
* Errors that an end user sees are a completely different thing. We strive to provide **minimal internal details** about an error for an end user when we know a user can't do anything about an error (e.g. "database offline error"), mostly it will be a generic "Inernal Server Error" on purpose -- for security reasons.
* Errors that an end user sees are a completely different thing. We strive to provide **minimal internal details** about an error for an end user when we know a user can't do anything about an error (e.g. "database offline error"), mostly it will be a generic "Internal Server Error" on purpose -- for security reasons.

### Producing errors

Expand Down Expand Up @@ -255,12 +255,12 @@ add [layers](https://docs.rs/tower/latest/tower/trait.Layer.html)
and [services](https://docs.rs/tower/latest/tower/trait.Service.html) as middleware to your routes and handlers.

Middleware is a way to add pre- and post-processing to your requests. This can be used for logging, authentication, rate
limiting, route specific processing, and more.
limiting, route-specific processing, and more.


### Source Code

`Loco`'s implementation of route middleware / layer is similar
`Loco`'s implementation of route middleware/layer is similar
to `axum`'s [`Router::layer`](https://github.com/tokio-rs/axum/blob/main/axum/src/routing/mod.rs#L275). You can
find the source code for middleware in
the [`src/controllers/routes`](https://github.com/loco-rs/loco/blob/master/src/controller/routes.rs) directory.
Expand Down Expand Up @@ -439,7 +439,7 @@ path. Then we are calling the inner service with the request.
In the Tower framework, before a service can be used to handle a request, it must be
checked for readiness
using the
poll_ready method. This method returns `Poll::Ready(Ok(()))` when the service is ready to process a request. If a
`poll_ready` method. This method returns `Poll::Ready(Ok(()))` when the service is ready to process a request. If a
service is not ready, it may return `Poll::Pending`, indicating that the caller should wait before sending a request.
This mechanism ensures that the service has the necessary resources or state to process the request efficiently and
correctly.
Expand All @@ -462,7 +462,7 @@ verified as ready. Here’s how it works:
- Replace the original with the clone: Use `std::mem::replace` to swap the original service with the clone. This
operation ensures that the service handler continues to hold a service instance.
- Use the original service to handle the request: Since the original service was already checked for readiness (via
poll_ready), it's safe to use it to handle the incoming request. The clone, now in the handler, will be the one
`poll_ready`), it's safe to use it to handle the incoming request. The clone, now in the handler, will be the one
checked for readiness next time.

This method ensures that each service instance used to handle requests is always the one that has been explicitly
Expand Down
4 changes: 1 addition & 3 deletions loco-gen/src/templates/scaffold/html/controller.t
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,5 @@ pub fn routes() -> Routes {
.add(":id", get(show))
.add(":id/edit", get(edit))
.add(":id", delete(remove))
.add(":id", put(update))
.add(":id", patch(update))
}
.add(":id", post(update))
}
2 changes: 1 addition & 1 deletion loco-gen/src/templates/scaffold/htmx/view_edit.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Edit {{name}}: {% raw %}{{ item.id }}{% endraw %}
{% raw %}{% block content %}{% endraw %}
<h1>Edit {{name}}: {% raw %}{{ item.id }}{% endraw %}</h1>
<div class="mb-10">
<form hx-post="/{{name | plural}}/{% raw %}{{ item.id }}{% endraw %}" hx-ext="submitjson" hx-target="#success-message">
<form hx-put="/{{name | plural}}/{% raw %}{{ item.id }}{% endraw %}" hx-ext="submitjson" hx-target="#success-message">
<div class="mb-5">
{% for column in columns -%}
<div>
Expand Down

0 comments on commit 248e51c

Please sign in to comment.