Project updates from Template

This commit contains the latest updates from the generic Website template, which rework the compression and localization:

- Reworked the compression and localization in the Infrastructure package. (3c568e4)
- Adopted the reworked compression and localization in the Website service. (08cf3e3)

The template commit that only touched the root README (53676ed) was left out, as this project no longer carries that file.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
2026-09-20 12:45:58 +02:00
co-authored by Claude Fable 5.1
parent 65b62681eb
commit 916df7e2f0
24 changed files with 426 additions and 218 deletions
@@ -2,31 +2,30 @@ import Foundation
import HTTPTypes
import Hummingbird
import HummingbirdTesting
import Localization
import NIOCore
import Testing
@testable import Infrastructure
@Suite(
"LocalizationMiddleware middleware",
.tags(.middleware)
"Negotiate+Request extension",
.tags(.extension)
)
struct LocalizationMiddlewareTests {
struct NegotiateRequestTests {
// MARK: Constants
/// Exercised through a route rather than a hand-built `Request`: the query parameter and path segment it reads are parsed from the URI.
private let app: Application = .init(router: {
let negotiate = Negotiate(bundle: .module)
let router = Router(context: StubRequestContext.self)
router.addMiddleware {
LocalizationMiddleware(bundle: .module)
router.get("language") { request, _ in
negotiate(for: request)
}
router.get("language") { _, context in
context.language
}
router.get("de/language") { _, context in
context.language
router.get("de/language") { request, _ in
negotiate(for: request)
}
return router
@@ -18,7 +18,6 @@ struct NotFoundMiddlewareTests {
let router = Router(context: StubRequestContext.self)
router.addMiddleware {
LocalizationMiddleware(bundle: .module)
NotFoundMiddleware(bundle: .module) {
StubPage(locale: $0)
}
@@ -179,7 +178,6 @@ private extension NotFoundMiddlewareTests {
let router = Router(context: StubRequestContext.self)
router.addMiddleware {
LocalizationMiddleware(bundle: .module)
NotFoundMiddleware(bundle: .module) {
StubPage(
locale: $0,
@@ -1,17 +1,14 @@
import Hummingbird
import Infrastructure
/// A ``LocalizedRequestContext`` carrying the core storage and the negotiated language only.
struct StubRequestContext: LocalizedRequestContext {
/// A request context carrying the core storage and nothing else.
struct StubRequestContext: RequestContext {
// MARK: Properties
/// The core request context storage Hummingbird requires.
var coreContext: CoreRequestContextStorage
/// The language identifier negotiated for the request.
var language: String
// MARK: Initializers
/// Creates a request context for the given source.
@@ -20,7 +17,6 @@ struct StubRequestContext: LocalizedRequestContext {
source: Source
) {
self.coreContext = .init(source: source)
self.language = ""
}
}