{"id":20037990,"url":"https://github.com/perfectlysoft/perfect-httpserver","last_synced_at":"2025-10-06T17:05:22.975Z","repository":{"id":54331714,"uuid":"62731283","full_name":"PerfectlySoft/Perfect-HTTPServer","owner":"PerfectlySoft","description":"HTTP server for Perfect.","archived":false,"fork":false,"pushed_at":"2020-07-17T15:52:50.000Z","size":938,"stargazers_count":108,"open_issues_count":16,"forks_count":63,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-12-13T14:02:51.564Z","etag":null,"topics":["http","httpserver","perfect","server-side-swift","swift"],"latest_commit_sha":null,"homepage":"https://www.perfect.org","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PerfectlySoft.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":"2016-07-06T15:17:42.000Z","updated_at":"2024-07-16T13:21:12.000Z","dependencies_parsed_at":"2022-08-13T12:20:09.576Z","dependency_job_id":null,"html_url":"https://github.com/PerfectlySoft/Perfect-HTTPServer","commit_stats":null,"previous_names":[],"tags_count":85,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectlySoft%2FPerfect-HTTPServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectlySoft%2FPerfect-HTTPServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectlySoft%2FPerfect-HTTPServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerfectlySoft%2FPerfect-HTTPServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PerfectlySoft","download_url":"https://codeload.github.com/PerfectlySoft/Perfect-HTTPServer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230523761,"owners_count":18239445,"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":["http","httpserver","perfect","server-side-swift","swift"],"created_at":"2024-11-13T10:24:32.460Z","updated_at":"2025-10-06T17:05:17.956Z","avatar_url":"https://github.com/PerfectlySoft.png","language":"Swift","readme":"# Perfect-HTTPServer [简体中文](README.zh_CN.MD)\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"http://perfect.org/get-involved.html\" target=\"_blank\"\u003e\n        \u003cimg src=\"http://perfect.org/assets/github/perfect_github_2_0_0.jpg\" alt=\"Get Involed with Perfect!\" width=\"854\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/PerfectlySoft/Perfect\" target=\"_blank\"\u003e\n        \u003cimg src=\"http://www.perfect.org/github/Perfect_GH_button_1_Star.jpg\" alt=\"Star Perfect On Github\" /\u003e\n    \u003c/a\u003e  \n    \u003ca href=\"http://stackoverflow.com/questions/tagged/perfect\" target=\"_blank\"\u003e\n        \u003cimg src=\"http://www.perfect.org/github/perfect_gh_button_2_SO.jpg\" alt=\"Stack Overflow\" /\u003e\n    \u003c/a\u003e  \n    \u003ca href=\"https://twitter.com/perfectlysoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"http://www.perfect.org/github/Perfect_GH_button_3_twit.jpg\" alt=\"Follow Perfect on Twitter\" /\u003e\n    \u003c/a\u003e  \n    \u003ca href=\"http://perfect.ly\" target=\"_blank\"\u003e\n        \u003cimg src=\"http://www.perfect.org/github/Perfect_GH_button_4_slack.jpg\" alt=\"Join the Perfect Slack\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://developer.apple.com/swift/\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat\" alt=\"Swift 4.0\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://developer.apple.com/swift/\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Platforms-OS%20X%20%7C%20Linux%20-lightgray.svg?style=flat\" alt=\"Platforms OS X | Linux\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://perfect.org/licensing.html\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/License-Apache-lightgrey.svg?style=flat\" alt=\"License Apache\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://twitter.com/PerfectlySoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Twitter-@PerfectlySoft-blue.svg?style=flat\" alt=\"PerfectlySoft Twitter\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://perfect.ly\" target=\"_blank\"\u003e\n        \u003cimg src=\"http://perfect.ly/badge.svg\" alt=\"Slack Status\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\nHTTP Server for Perfect\n\nThis repository contains the main HTTP 1.1 \u0026amp; HTTP/2 server.\n\nIf you are using this server for your Perfect Server-Side Swift project then this will be the main dependency for your project.\n\n```swift\n.package(url: \"https://github.com/PerfectlySoft/Perfect-HTTPServer.git\", from: \"3.0.0\")\n```\n\nIf you are starting out with Perfect look at the main [Perfect](https://github.com/PerfectlySoft/Perfect) repository for details.\n\nIf you are beginning a new project with Perfect look at the [PerfectTemplate](https://github.com/PerfectlySoft/PerfectTemplate) project for starter instructions.\n\nWhen building on Linux, OpenSSL 1.0.2+ is required for this package. On Ubuntu 14 or some Debian distributions you will need to update your OpenSSL before this package will build.\n\n### HTTP/2\n\nAs of version 2.2.6, experimental HTTP/2 server support is available but is disabled by default. To enable HTTP/2, add \"alpnSupport\" to your server's TLSConfiguration struct:\n\n```swift\nlet securePort = 8181\nlet tls = TLSConfiguration(certPath: \"my.cert.pem\", \n\t\t\t\t\t\talpnSupport: [.http2, .http11])\n\ntry HTTPServer.launch(\n\t.secureServer(tls,\n\t              name: \"servername\",\n\t              port: securePort,\n\t              routes: secureRoutes))\n```\n\nThis will enable HTTP/2 to be used over secure connections if the client supports it. If the client does not support HTTP/2 then the server will use HTTP 1.x. HTTP/2 support is only offered over secure connections. Setting the global `http2Debug` variable to true will have the HTTP/2 server print much debugging information to the console while in use.\n\nPlease contact us if you experience any problems or incompatibilities while experimenting with HTTP/2 support.\n\n## QuickStart\n\nAdd the dependency to your Package.swift\n\n`.package(url: \"https://github.com/PerfectlySoft/Perfect-HTTPServer.git\", from: \"3.0.0\")`\n\nIn your app, launch one or more servers.\n```\n// start a single server serving static files\ntry HTTPServer.launch(name: \"localhost\", port: 8080, documentRoot: \"/path/to/webroot\")\n \n// start two servers. have one serve static files and the other handle API requests\nlet apiRoutes = Route(method: .get, uri: \"/foo/bar\", handler: {\n        req, resp in\n        //do stuff\n    })\ntry HTTPServer.launch(\n    .server(name: \"localhost\", port: 8080, documentRoot:  \"/path/to/webroot\"),\n    .server(name: \"localhost\", port: 8181, routes: [apiRoutes]))\n \n// start a single server which handles API and static files\ntry HTTPServer.launch(name: \"localhost\", port: 8080, routes: [\n    Route(method: .get, uri: \"/foo/bar\", handler: {\n        req, resp in\n        //do stuff\n    }),\n    Route(method: .get, uri: \"/foo/bar\", handler:\n        HTTPHandler.staticFiles(documentRoot: \"/path/to/webroot\"))\n    ])\n \nlet apiRoutes = Route(method: .get, uri: \"/foo/bar\", handler: {\n        req, resp in\n        //do stuff\n    })\n// start a secure server\ntry HTTPServer.launch(.secureServer(TLSConfiguration(certPath: \"/path/to/cert\"), name: \"localhost\", port: 8080, routes: [apiRoutes]))\n```\n\n## Documentation\n\nFor further information, please visit [perfect.org](http://www.perfect.org/docs/HTTPServer.html).\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperfectlysoft%2Fperfect-httpserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperfectlysoft%2Fperfect-httpserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperfectlysoft%2Fperfect-httpserver/lists"}