# Resource‑centric Swift server framework

**URL:** <https://forums.swift.org/t/resource-centric-swift-server-framework/84029>\
**Category:** Pitches\
**Tags:** framework\
**Created:** [January 8, 2026, 10:59pm UTC](https://forums.swift.org/t/resource-centric-swift-server-framework/84029 "2026-01-08T22:59:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![progalgo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/progalgo/32/41233_2.png) [@progalgo](https://forums.swift.org/u/progalgo)\
**Post date:** [January 8, 2026, 10:59pm UTC](https://forums.swift.org/t/resource-centric-swift-server-framework/84029/1 "2026-01-08T22:59:17Z")

</div>

This pitch outlines an idea for a **resource‑centric** Swift server framework, intended for discussion and design exploration within SSWG. The core idea is to treat **HTTP resources as first‑class types** , rather than routing strings to handlers, addressing a common limitation of route‑centric frameworks where the HTTP resource model is implicit or obscured.

Inspired by the HTTP specification, the framework would model _resources_ and their _representations_, with supported HTTP methods emerging naturally from resource capabilities.

Rather than registering routes, developers declare and compose resources hierarchically. Each resource explicitly defines which HTTP methods it supports and how representations are produced or consumed. The tree composition of URLs is inspired by SwiftUI.

* * *

#### Minimal example: product catalog microservice

```swift
@main
struct CatalogService: HTTPService {
    var resources: some ResourceTree {
        ResourceCollection<Product>("products") {

            /// This handles GET /products
            func get() async throws -> [Product] {
                ...
            }

            /// This handles POST /products
            func post(_ product: ProductDraft) async throws -> Product {
                ...
            }
        }
    }
}

struct Product: Resource {
    let id: UUID
    let name: String
    let price: Decimal
}

struct ProductDraft: Codable {
    let name: String
    let price: Decimal
}

```

Here, `/products` is a concrete resource. Its supported HTTP methods and representations are defined directly in code, making HTTP semantics explicit rather than encoded in external routing configuration.

The API is work in progress, suggestions are welcome.

---

<div class="post-metadata">

**Author:** ![ktoso](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ktoso/32/44526_2.png) [@ktoso](https://forums.swift.org/u/ktoso)\
**Post date:** [January 9, 2026, 12:45am UTC](https://forums.swift.org/t/resource-centric-swift-server-framework/84029/2 "2026-01-09T00:45:53Z")

</div>

As web framework styles often end up betting a matter of personal taste and preference I don’t think there’s anything the SSWG needs to be “reviewing” here in a pitch/review sense.

Sure, go for it if that’s a style of framework you’re interested in.

---

<div class="post-metadata">

**Author:** ![adam-fowler](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/adam-fowler/32/9266_2.png) [@adam-fowler](https://forums.swift.org/u/adam-fowler)\
**Post date:** [January 13, 2026, 12:46pm UTC](https://forums.swift.org/t/resource-centric-swift-server-framework/84029/3 "2026-01-13T12:46:42Z")

</div>

I’m sure you could model this on top of Vapor or Hummingbird. I don’t think you need a new server implementation. Both have a concept of route collections which could be used to collect the series of endpoints generated for each of your resource collection.
