Configs2026年7月1日·1 分钟阅读

Kitura — Server-Side Swift Web Framework

Kitura is a server-side Swift web framework originally developed by IBM that provides an expressive router, Codable-based JSON handling, and middleware support for building REST APIs and web applications on Linux and macOS.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Kitura Framework
直接安装命令
npx -y tokrepo@latest install e708c36a-7568-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Kitura is a server-side Swift web framework that brings the safety and expressiveness of Swift to backend development. Originally created by IBM, it provides a performant HTTP server, a flexible router, and Codable routing that maps JSON payloads directly to Swift structs.

What Kitura Does

  • Routes HTTP requests to handler closures with typed parameters
  • Serializes and deserializes JSON payloads via Swift's Codable protocol
  • Supports pluggable middleware for sessions, compression, and authentication
  • Serves static files and renders templates through Stencil or Markdown engines
  • Runs on both Linux and macOS using Swift's cross-platform Foundation layer

Architecture Overview

Kitura is built on top of a custom non-blocking I/O layer (BlueSocket/NIO). Incoming connections are dispatched through a middleware chain, matched against the router's path tree, and handled by registered closures. Codable routing eliminates manual JSON parsing by decoding request bodies and encoding responses using Swift's built-in Codable machinery.

Self-Hosting & Configuration

  • Requires Swift 5.2+ on Linux (Ubuntu, RHEL) or macOS
  • Add Kitura as a Swift Package Manager dependency in Package.swift
  • Bind host and port with Kitura.addHTTPServer(onPort:)
  • Enable HTTPS by passing SSLConfig with certificate and key paths
  • Deploy as a compiled binary behind Nginx or in a Docker container

Key Features

  • Codable routing maps request/response bodies directly to Swift structs
  • Type-safe route parameters reduce runtime errors
  • Middleware pipeline supports CORS, helmet-style security headers, and sessions
  • Built-in support for OpenAPI spec generation from route definitions
  • Compatible with the broader Swift on Server ecosystem (SwiftNIO, Swift-Log)

Comparison with Similar Tools

  • Vapor — the most popular Swift server framework; Kitura offers Codable routing as a differentiator
  • Perfect — another early Swift server framework; Kitura has stronger middleware composition
  • Hummingbird — lightweight Swift server; Kitura provides more built-in features
  • Express (Node.js) — similar middleware model; Kitura uses Swift's type system for safety
  • Actix Web (Rust) — compile-time safety like Swift; Kitura is easier to pick up for iOS developers

FAQ

Q: Is Kitura still maintained? A: IBM transferred Kitura to the community. It receives maintenance updates but active feature development has slowed.

Q: Can I share code between an iOS app and a Kitura backend? A: Yes. Shared Swift packages work across iOS and server targets, which is a key advantage of server-side Swift.

Q: Does Kitura support WebSockets? A: Yes. The Kitura-WebSocket package provides WebSocket server support.

Q: How does performance compare to Vapor? A: Both are comparable for typical API workloads. Vapor has moved to SwiftNIO while Kitura uses its own I/O layer.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产