-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
117 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
organization := "me.arcanis" | ||
|
||
name := "ffxivbis" | ||
|
||
scalaVersion := "2.13.6" | ||
|
||
scalacOptions ++= Seq("-deprecation", "-feature") | ||
|
||
enablePlugins(JavaAppPackaging) | ||
coverageEnabled := true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version = 1.6.1 | ||
sbt.version = 1.5.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/scala/me/arcanis/ffxivbis/http/api/v1/StatusEndpoint.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2019-2022 Evgeniy Alekseev. | ||
* | ||
* This file is part of ffxivbis | ||
* (see https://github.com/arcan1s/ffxivbis). | ||
* | ||
* License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
package me.arcanis.ffxivbis.http.api.v1 | ||
|
||
import akka.http.scaladsl.server.Directives._ | ||
import akka.http.scaladsl.server._ | ||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.media.{Content, Schema} | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse | ||
import jakarta.ws.rs._ | ||
import me.arcanis.ffxivbis.http.api.v1.json._ | ||
|
||
@Path("/api/v1") | ||
class StatusEndpoint extends JsonSupport { | ||
|
||
def route: Route = getServerStatus | ||
|
||
@GET | ||
@Path("status") | ||
@Produces(value = Array("application/json")) | ||
@Operation( | ||
summary = "server status", | ||
description = "Returns the server status descriptor", | ||
responses = Array( | ||
new ApiResponse( | ||
responseCode = "200", | ||
description = "Service status descriptor", | ||
content = Array(new Content(schema = new Schema(implementation = classOf[StatusModel]))) | ||
), | ||
new ApiResponse( | ||
responseCode = "500", | ||
description = "Internal server error", | ||
content = Array(new Content(schema = new Schema(implementation = classOf[ErrorModel]))) | ||
), | ||
), | ||
tags = Array("status"), | ||
) | ||
def getServerStatus: Route = | ||
path("status") { | ||
get { | ||
complete { | ||
StatusModel( | ||
version = Option(getClass.getPackage.getImplementationVersion), | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/scala/me/arcanis/ffxivbis/http/api/v1/json/StatusModel.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright (c) 2019-2022 Evgeniy Alekseev. | ||
* | ||
* This file is part of ffxivbis | ||
* (see https://github.com/arcan1s/ffxivbis). | ||
* | ||
* License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
package me.arcanis.ffxivbis.http.api.v1.json | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
case class StatusModel(@Schema(description = "server version") version: Option[String]) |
29 changes: 29 additions & 0 deletions
29
src/test/scala/me/arcanis/ffxivbis/http/api/v1/StatusEndpointTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package me.arcanis.ffxivbis.http.api.v1 | ||
|
||
import akka.http.scaladsl.model.StatusCodes | ||
import akka.http.scaladsl.testkit.ScalatestRouteTest | ||
import com.typesafe.config.Config | ||
import me.arcanis.ffxivbis.Settings | ||
import me.arcanis.ffxivbis.http.api.v1.json._ | ||
import org.scalatest.matchers.should.Matchers | ||
import org.scalatest.wordspec.AnyWordSpecLike | ||
|
||
import scala.language.postfixOps | ||
|
||
class StatusEndpointTest extends AnyWordSpecLike | ||
with Matchers with ScalatestRouteTest with JsonSupport { | ||
|
||
override val testConfig: Config = Settings.withRandomDatabase | ||
|
||
private val route = new StatusEndpoint().route | ||
|
||
"api v1 status endpoint" must { | ||
|
||
"return server status" in { | ||
Get("/status") ~> route ~> check { | ||
status shouldEqual StatusCodes.OK | ||
} | ||
} | ||
|
||
} | ||
} |