{"id":15798202,"url":"https://github.com/grokify/fastly-compute-quickstart-swift","last_synced_at":"2025-03-31T20:12:03.660Z","repository":{"id":41136061,"uuid":"506753051","full_name":"grokify/fastly-compute-quickstart-swift","owner":"grokify","description":"Quickstart for Swift on Fastly Compute@Edge","archived":false,"fork":false,"pushed_at":"2022-07-16T04:56:34.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-12T00:51:34.847Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grokify.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-23T18:39:22.000Z","updated_at":"2022-07-15T21:03:40.000Z","dependencies_parsed_at":"2022-07-13T19:10:41.883Z","dependency_job_id":null,"html_url":"https://github.com/grokify/fastly-compute-quickstart-swift","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grokify%2Ffastly-compute-quickstart-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grokify%2Ffastly-compute-quickstart-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grokify%2Ffastly-compute-quickstart-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grokify%2Ffastly-compute-quickstart-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grokify","download_url":"https://codeload.github.com/grokify/fastly-compute-quickstart-swift/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246531975,"owners_count":20792736,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-05T00:23:59.880Z","updated_at":"2025-03-31T20:12:03.640Z","avatar_url":"https://github.com/grokify.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fastly Compute@Edge Quickstart for Swift\n\nThis is an example Fastly Compute@Edge app using [Andrew Barba's Swift Compute Runtime SDK](https://github.com/AndrewBarba/swift-compute-runtime).\n\nIt's designed to demonistrate some simple functionality:\n\n1. Routing\n1. Accessing request object (method, url, headers)\n1. Writing repsponse (JSON and text)\n1. Setting response status (200 vs. 404)\n\nSee the [SDK Reference](https://compute-runtime.swift.cloud/documentation/compute/) for more info.\n\n## Synopsis\n\nThe following is the code for this demo.\n\n```swift\nimport Compute\n\nstruct Response: Codable {\n    let version: Int\n    let message: String\n}\n\n@main\nstruct ComputeApp {\n    static func main() async throws {\n        try await onIncomingRequest { req, res in\n            let logger = try Logger(name: \"QuickstartLog\")\n            switch (req.method, req.url.path) {\n            case (.post, \"/quickstart\"):\n                if let accept = req.headers.get(\"Accept\") {\n                    if accept.caseInsensitiveCompare(\"text/plain\") == .orderedSame {\n                        try logger.write(\"swift quickstart responded with 200\")\n                        try await res.status(200).send(\"Hello, Swift World!\")\n                        return\n                    }\n                }\n                let content = Response(version: 1, message: \"Hello, Swift World!\")\n                try logger.write(\"swift quickstart responded with 200\")\n                try await res.status(200).send(content)\n            default:\n                try logger.write(\"swift quickstart responded with 404\")\n                try await res.status(404).send()\n            }\n        }\n    }\n}\n```\n\n## Prerequisites\n\n1. [SwiftWasm toolchain](https://book.swiftwasm.org/getting-started/setup.html)\n1. [Fastly CLI](https://github.com/fastly/cli)\n\n## Usage\n\n``` bash\n$ fastly compute init\n$ /Library/Developer/Toolchains/swift-wasm-5.6.0-RELEASE.xctoolchain/usr/bin/swift build --triple wasm32-unknown-wasi --product FastlyComputeQuickstart -c release\n$ fastly compute pack --wasm-binary=./.build/release/FastlyComputeQuickstart.wasm\n$ fastly compute deploy\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrokify%2Ffastly-compute-quickstart-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrokify%2Ffastly-compute-quickstart-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrokify%2Ffastly-compute-quickstart-swift/lists"}