Skip to content

Application

Josh Wright edited this page Jan 14, 2021 · 4 revisions

Application

The core type for an Alchemy application. Implement this & it's setup function, then call MyApplication.launch() in your main.swift.

public protocol Application
// MyApplication.swift
struct App: Application {
    func setup() {
        self.get("/hello") { _ in
            "Hello, world!"
        }
        ...
    }
}

// main.swift
App.launch()

Requirements

setup()

Called before any launch command is run. Called AFTER any environment is loaded and the global MultiThreadedEventLoopGroup is set. Called on an event loop, so Services.eventLoop is available for use if needed.

func setup()
Alchemy
Types
Protocols
Global Typealiases
Global Variables
Global Functions
Fusion
Types
Protocols
Papyrus
Types
Protocols
Clone this wiki locally