Skip to content

Instantly share code, notes, and snippets.

View adam-fowler's full-sized avatar

Adam Fowler adam-fowler

View GitHub Profile
@adam-fowler
adam-fowler / server.swift
Last active January 12, 2025 11:55
NIOAsyncChannel server
import NIOCore
import NIOHTTP1
import NIOPosix
/// Sendable server response that doesn't use ``IOData``
public typealias SendableHTTPServerResponsePart = HTTPPart<HTTPResponseHead, ByteBuffer>
/// Channel to convert HTTPServerResponsePart to the Sendable type HBHTTPServerResponsePart
final class HTTPSendableResponseChannelHandler: ChannelOutboundHandler, RemovableChannelHandler {
typealias OutboundIn = SendableHTTPServerResponsePart
@adam-fowler
adam-fowler / MultipartFile.swift
Created May 12, 2025 16:39
MultipartFile upload
import Hummingbird
import MultipartKit
import NIOCore
import NIOHTTP1
import StructuredFieldValues
struct FileUpload: Decodable {
let upload: File
}
@adam-fowler
adam-fowler / XCTAssert(Not)Equal
Last active June 20, 2025 10:48 — forked from ptoffy/XCTAssert(Not)Nil
Swift Testing Migration Utilities
replace: (try\s+)?XCTAssertEqual\((.*),\s*([^,]+)\)
with: #expect($2 == $3)
replace: (try\s+)?XCTAssertNotEqual\((.*),\s*([^,]+)\)
with: #expect($2 != $3)