[+] Create function to compose urls

This commit is contained in:
Hykilpikonna
2021-01-09 10:57:35 -05:00
parent a07595de0c
commit ef9e13e870
2 changed files with 25 additions and 0 deletions
+4
View File
@@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
4F8A607125A9160400D88DC3 /* AddAlarmViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8A607025A9160400D88DC3 /* AddAlarmViewController.swift */; };
4F8A607525A919E600D88DC3 /* Logic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8A607425A919E600D88DC3 /* Logic.swift */; };
4F98955225A9260400F51321 /* Net.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F98955125A9260400F51321 /* Net.swift */; };
4FF0683F25A5F18700304E6B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0683E25A5F18700304E6B /* AppDelegate.swift */; };
4FF0684125A5F18700304E6B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0684025A5F18700304E6B /* SceneDelegate.swift */; };
4FF0684325A5F18700304E6B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0684225A5F18700304E6B /* ViewController.swift */; };
@@ -20,6 +21,7 @@
/* Begin PBXFileReference section */
4F8A607025A9160400D88DC3 /* AddAlarmViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAlarmViewController.swift; sourceTree = "<group>"; };
4F8A607425A919E600D88DC3 /* Logic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logic.swift; sourceTree = "<group>"; };
4F98955125A9260400F51321 /* Net.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Net.swift; sourceTree = "<group>"; };
4FF0683B25A5F18700304E6B /* ProjectClock.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ProjectClock.app; sourceTree = BUILT_PRODUCTS_DIR; };
4FF0683E25A5F18700304E6B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
4FF0684025A5F18700304E6B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
@@ -69,6 +71,7 @@
4FF0684925A5F18800304E6B /* LaunchScreen.storyboard */,
4FF0684C25A5F18800304E6B /* Info.plist */,
4F8A607425A919E600D88DC3 /* Logic.swift */,
4F98955125A9260400F51321 /* Net.swift */,
);
path = ProjectClock;
sourceTree = "<group>";
@@ -144,6 +147,7 @@
buildActionMask = 2147483647;
files = (
4F8A607125A9160400D88DC3 /* AddAlarmViewController.swift in Sources */,
4F98955225A9260400F51321 /* Net.swift in Sources */,
4F8A607525A919E600D88DC3 /* Logic.swift in Sources */,
4FF0684325A5F18700304E6B /* ViewController.swift in Sources */,
4FF0683F25A5F18700304E6B /* AppDelegate.swift in Sources */,
+21
View File
@@ -0,0 +1,21 @@
//
// ProjectClock
//
// Created by Hykilpikonna on 1/8/21.
//
import Foundation
let baseUrl = "http://localhost:8080/api/" // TODO: Production settings
/// Build a URL with the node path and params
func buildUrl(_ node: String, _ params: [String: String]?) -> URL
{
var url = URLComponents(string: baseUrl + node)
if let params = params
{
url?.queryItems = params.map { URLQueryItem(name: $0, value: $1) }
}
return url!.url!
}