Skip to content

Commit

Permalink
Merge pull request #8 from fa21-collaborative-drone-interactions/feat…
Browse files Browse the repository at this point in the history
…ure/sensor-names

Provide sensor names on endpoint
  • Loading branch information
Lerbert authored Sep 26, 2021
2 parents ed43eec + d4a73ee commit 9176420
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 21 deletions.
10 changes: 5 additions & 5 deletions WebService/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ RUN swift build --package-path ./WebService
WORKDIR /staging

# Copy main executable to staging area
RUN cp "$(swift build --package-path /build/WebService --show-bin-path)/Demo" ./
RUN cp "$(swift build --package-path /build/WebService --show-bin-path)/Buoy" ./

# Copy resources from the resources directory if the directories exist
# Ensure that by default, neither the directory nor any of its contents are writable.
RUN [ -d "$(swift build --package-path /build/WebService --show-bin-path)/WebService_Demo.resources" ] \
&& mv "$(swift build --package-path /build/WebService --show-bin-path)/WebService_Demo.resources" ./ \
&& chmod -R a-w ./WebService_Demo.resources \
RUN [ -d "$(swift build --package-path /build/WebService --show-bin-path)/WebService_Buoy.resources" ] \
&& mv "$(swift build --package-path /build/WebService --show-bin-path)/WebService_Buoy.resources" ./ \
&& chmod -R a-w ./WebService_Buoy.resources \
|| echo No resources to copy

# ================================
Expand Down Expand Up @@ -57,4 +57,4 @@ USER apodini:apodini

# Start the Apodini service when the image is run.
# The default port is 80. Can be adapted using the `--port` argument
ENTRYPOINT ["./Demo"]
ENTRYPOINT ["./Buoy"]
12 changes: 6 additions & 6 deletions WebService/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ import PackageDescription


let package = Package(
name: "Demo",
name: "Buoy",
platforms: [
.macOS(.v12)
],
products: [
.executable(
name: "Demo",
targets: ["Demo"]
name: "Buoy",
targets: ["Buoy"]
)
],
dependencies: [
.package(url: "https://github.com/Apodini/Apodini.git", .upToNextMinor(from: "0.5.0"))
],
targets: [
.executableTarget(
name: "Demo",
name: "Buoy",
dependencies: [
.product(name: "Apodini", package: "Apodini"),
.product(name: "ApodiniREST", package: "Apodini"),
.product(name: "ApodiniOpenAPI", package: "Apodini")
]
),
.testTarget(
name: "DemoTests",
name: "BuoyTests",
dependencies: [
.target(name: "Demo")
.target(name: "Buoy")
]
)
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ArgumentParser


@main
struct DemoWebService: WebService {
struct BuoyWebService: WebService {
@Option(help: "The port the web service is offered at")
var port: Int = 80

Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions WebService/Sources/Buoy/Sensor.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Apodini
import Foundation


struct Sensor: Handler {
func handle() -> [SensorDescription] {
readJSONFromFile([SensorType].self, filePath: "available_sensors.json")?.map { SensorDescription(type: $0) } ?? []
}
}

struct SensorDescription: Content {
let name: String
let type: SensorType

init(type: SensorType) {
self.type = type
self.name = type.description
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 0 additions & 9 deletions WebService/Sources/Demo/Sensor.swift

This file was deleted.

File renamed without changes.

0 comments on commit 9176420

Please sign in to comment.