Skip to content

a lean & mean fork of Swifter http server refactored by Todd Bruss

License

Notifications You must be signed in to change notification settings

StarPlayrX/SwifterLite

 
 

Repository files navigation

Platform Swift Protocols

What is SwifterLite?

Unofficial fork of Swifter written in Swift programming language, designed to be an embedded REST API server for iOS macOS and tvOS. This fork focuses on speed and reliability with the ability to stream audio and video seamlessly on or to any Apple device. SwifterLite can also become a REST api middleware and use it as an abstraction layer making it easier to update the middleware instead if your main app.

Supports data, json, ping (text), bytes, audio and video streaming over HLS, over HTTP 1.1 protocol via http://localhost, ipv4 tcp ip

SwifterLite is used in StarPlayrX and future IPTVee works by Todd Bruss. This library uses a subset of features available in Swifter. Please do not attempt to merge it into http/Swifter as there are many changes and some pieces will not be available. SwifterLite is approximately 50% the size of the original Swifter repo.

SwifterLite is one of the most reliable server side swift frameworks to date. It is also lean & mean. If you want https compability, you can easily combine it with nginx and cloudflare https.

Branches

mustang

To Do REST API examples to be expanded

Swift Package Manager

import PackageDescription

let package = Package(
    name: "YourServerName",
    products: [
        .library(
            name: "YourServerName",
            targets: ["YourServerName"]),
    ],
    dependencies: [
        .package(url: "https://github.com/StarPlayrX/SwifterLite", branch: "mustang")
    ],
    targets: [
        .target(
            name: "YourServerName",
            dependencies: [.product(name: "SwifterLite", package: "SwifterLite")]
        ),
    ]
)

import SwifterLite

import SwifterLite

How to start server with 1 route and select its port

let server = HttpServer()
server.get["/api/v3/ping"] = { request in
    return HttpResponse.ok(.ping("pong"))
}
let port = 8080
try? server.start(port)

Data Route

func dataRoute(_ data: Data) -> httpReq {{ request in
    return HttpResponse.ok(.data(data, contentType: "application/octet-stream"))
}}

let data = Data("commanderData".utf8)
server.get["/commander/data"] = dataRoute(data: data)

For more examples please see StarPlayrRadioKit which uses SwifterLite

About

a lean & mean fork of Swifter http server refactored by Todd Bruss

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%