目录

VeloxServe

Experimental, lightweight Swift HTTP server built on SwiftNIO with fully async API.

Example

You respond to HTTP requests by providing an async function (RequestReader, inout ResponseWriter) async throws -> Void to the server. Within in this function you can read the request from the given RequestReader struct and write you response to the ResponseWriter struct. Returning from this function (or throwing an error) indicates that you are done with the response.

import VeloxServe

let server = try await Server.start(
    host: "localhost", 
    port: 8080) { req, res in 
    try await res.plainText("Hello, World!\r\n")
}

logger.info("Server listening on: \(server.localAddress)")
try await server.run()
关于
50.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号