Coder Social home page Coder Social logo

trendingtechnology / hummingbird Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hummingbird-project/hummingbird

0.0 1.0 0.0 8.9 MB

Lightweight, flexible HTTP server framework written in Swift

License: Apache License 2.0

Swift 97.44% Shell 2.46% Dockerfile 0.11%

hummingbird's Introduction

Hummingbird

Lightweight, flexible server framework written in Swift.

Hummingbird consists of three main components, the core HTTP server, a minimal web application framework and the extension modules.

HummingbirdCore

HummingbirdCore contains a Swift NIO based HTTP server. You will find the code for it in the hummingbird-core repository. The HTTP server is initialized with a object conforming to protocol HBHTTPResponder which defines how your server responds to an HTTP request. The HTTP server can be extended to support TLS and HTTP2 via the HummingbirdTLS and HummingbirdHTTP2 libraries also available in the hummingbird-core repository.

HummingbirdCore can be used separately from Hummingbird if you want to write your own web application framework.

Hummingbird

Hummingbird is a lightweight and flexible web application framework that runs on top of HummingbirdCore. It is designed to require the minimum number of dependencies: swift-backtrace, swift-log, swift-nio, swift-nio-extras, swift-service-lifecycle and swift-metrics and makes no use of Foundation.

It provides a router for directing different endpoints to their handlers, middleware for processing requests before they reach your handlers and processing the responses returned, support for adding channel handlers to extend the HTTP server, extending the core HBApplication, HBRequest and HBResponse classes and providing custom encoding/decoding of Codable objects.

The interface is fairly standard. Anyone who has had experience of Vapor, Express.js etc will recognise most of the APIs. Simple setup is as follows

import Hummingbird

let app = HBApplication(configuration: .init(address: .hostname("127.0.0.1", port: 8080)))
app.router.get("hello") { request -> String in
    return "Hello"
}
try app.start()
app.wait()

Hummingbird Extensions

Hummingbird is designed to require the least number of dependencies possible, but this means many features are unavailable to the core libraries. Additional features are provided through extensions. The Hummingbird repository comes with a HummingbirdFoundation library that contains a number of features that can only really be implemented with the help of Foundation. This include JSON encoding/decoding, URLEncodedForms, static file serving, and cookies.

Extensions provided in other repositories include

Extension Description
HummingbirdAuth Authentication framework and various support libraries
HummingbirdCompress Request decompression and response compression (uses CompressNIO)
HummingbirdFluent Interface to the Vapor database ORM (uses FluentKit)
HummingbirdRedis Interface to Redis (uses RediStack)
HummingbirdWebSocket Adds support for WebSocket upgrade to server
HummingbirdMustache Mustache templating engine
HummingbirdLambda Run hummmingbird inside an AWS Lambda

Documentation

You can find reference documentation and user guides for Hummingbird here. The hummingbird-examples repository has a number of examples of different uses of the library.

hummingbird's People

Contributors

adam-fowler avatar softwareengineerchris avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.