mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-10 02:08:38 +09:00
Dactyloidae iOS initial commit
This commit is contained in:
parent
daa6179d22
commit
7154a0497e
2123 changed files with 197052 additions and 0 deletions
38
mobile/ios/Client/Frontend/Browser/AboutHomeHandler.swift
Normal file
38
mobile/ios/Client/Frontend/Browser/AboutHomeHandler.swift
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/**
|
||||
* Handles the page request to about/home/ so that the page loads and does not throw an error (404) on initialization
|
||||
*/
|
||||
import GCDWebServers
|
||||
|
||||
struct AboutHomeHandler {
|
||||
static func register(_ webServer: WebServer) {
|
||||
webServer.registerHandlerForMethod("GET", module: "about", resource: "home") { (request: GCDWebServerRequest?) -> GCDWebServerResponse! in
|
||||
return GCDWebServerResponse(statusCode: 200)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct AboutLicenseHandler {
|
||||
static func register(_ webServer: WebServer) {
|
||||
webServer.registerHandlerForMethod("GET", module: "about", resource: "license") { (request: GCDWebServerRequest?) -> GCDWebServerResponse! in
|
||||
let path = Bundle.main.path(forResource: "Licenses", ofType: "html")
|
||||
do {
|
||||
let html = try NSString(contentsOfFile: path!, encoding: String.Encoding.utf8.rawValue) as String
|
||||
return GCDWebServerDataResponse(html: html)
|
||||
} catch {
|
||||
print("Unable to register webserver \(error)")
|
||||
}
|
||||
return GCDWebServerResponse(statusCode: 200)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension GCDWebServerDataResponse {
|
||||
convenience init(XHTML: String) {
|
||||
let data = XHTML.data(using: String.Encoding.utf8, allowLossyConversion: false)
|
||||
self.init(data: data, contentType: "application/xhtml+xml; charset=utf-8")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue