Structures

The following structures are available globally.

  • Access environment variables

    See more

    Declaration

    Swift

    public struct HBEnvironment : Decodable, ExpressibleByDictionaryLiteral
  • Holds all the values required to process a request

    See more

    Declaration

    Swift

    public struct HBRequest : HBExtensible
  • Extend objects with additional member variables

    If you have only one instance of a type to attach you can extend it to conform to StorageKey

    struct Object {
        var extensions: Extensions<Object>
    }
    
    extension Object {
        var extra: Extra? {
            get { return extensions.get(\.extra) }
            set { extensions.set(\.extra, value: newValue) }
        }
    }
    
    See more

    Declaration

    Swift

    public struct HBExtensions<ParentObject>
  • Define media type of file

    See more

    Declaration

    Swift

    public struct HBMediaType : CustomStringConvertible
  • Undocumented

    See more

    Declaration

    Swift

    public struct HBURL : CustomStringConvertible, ExpressibleByStringLiteral
  • Store for parameters key, value pairs extracted from URI

    See more

    Declaration

    Swift

    public struct HBParameters
    extension HBParameters: Collection
  • Middleware implementing Cross-Origin Resource Sharing (CORS) headers.

    If request has “origin” header then generate CORS headers. If method is OPTIONS then return an empty body with all the standard CORS headers otherwise send request onto the next handler and when you receive the response add a “access-control-allow-origin” header

    See more

    Declaration

    Swift

    public struct HBCORSMiddleware : HBMiddleware
  • Middleware outputting to log for every call to server

    See more

    Declaration

    Swift

    public struct HBLogRequestsMiddleware : HBMiddleware
  • Middleware recording metrics for each request

    Records the number of requests, the request duration and how many errors were thrown. Each metric has additional dimensions URI and method.

    See more

    Declaration

    Swift

    public struct HBMetricsMiddleware : HBMiddleware
  • Holds all the required to generate a HTTP Response

    See more

    Declaration

    Swift

    public struct HBResponse : HBExtensible
    extension HBResponse: HBResponseGenerator
  • Used to group together routes under a single path. Additional middleware can be added to the endpoint and each route can add a suffix to the endpoint path

    The code below creates an HBRouterGroupwith path “todos” and adds GET and PUT routes on “todos” and adds GET, PUT and DELETE routes on “todos/:id” where id is the identifier for the todo

    app.router
    .group("todos")
    .get(use: todoController.list)
    .put(use: todoController.create)
    .get(":id", use: todoController.get)
    .put(":id", use: todoController.update)
    .delete(":id", use: todoController.delete)
    
    See more

    Declaration

    Swift

    public struct HBRouterGroup : HBRouterMethods
  • Undocumented

    See more

    Declaration

    Swift

    public struct HBRouterMethodOptions : OptionSet
  • Responder that calls supplied closure

    See more

    Declaration

    Swift

    public struct HBCallbackResponder : HBResponder
  • Used to Patch HTTPHeaders. Remembers if a header was added in with add or replaceOrAdd

    See more

    Declaration

    Swift

    public struct HTTPHeadersPatch : ExpressibleByDictionaryLiteral
  • Factory class for persist drivers

    See more

    Declaration

    Swift

    public struct HBPersistDriverFactory
  • Errors return by persist framework

    See more

    Declaration

    Swift

    public struct HBPersistError : Error, Equatable
  • Reader object for parsing String buffers

    See more

    Declaration

    Swift

    public struct HBParser
    extension HBParser: Sequence