add api document
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/7e4f6c81 Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/7e4f6c81 Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/7e4f6c81 Branch: refs/heads/master Commit: 7e4f6c81f61f6c718a5e8bdb4b53cb534c21c1b5 Parents: 455e155 Author: daewon <dae...@apache.org> Authored: Wed Dec 26 19:19:35 2018 +0900 Committer: daewon <dae...@apache.org> Committed: Wed Dec 26 19:19:35 2018 +0900 ---------------------------------------------------------------------- doc/source/conf.py | 2 ++ doc/source/index.rst | 1 + .../src/main/scala/org/apache/s2graph/http/Server.scala | 10 ++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7e4f6c81/doc/source/conf.py ---------------------------------------------------------------------- diff --git a/doc/source/conf.py b/doc/source/conf.py index afa4c10..5736d04 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -46,6 +46,8 @@ extensions = [ 'sphinx.ext.githubpages', ] +html_style = 'css/s2graph_style.css' + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7e4f6c81/doc/source/index.rst ---------------------------------------------------------------------- diff --git a/doc/source/index.rst b/doc/source/index.rst index 83bf8d5..fd4e755 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -20,6 +20,7 @@ d...@s2graph.incubator.apache.org is for people who want to contribute to S2Graph getting_started/index getting_started/your_first_graph + api/index .. Indices and tables http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7e4f6c81/s2http/src/main/scala/org/apache/s2graph/http/Server.scala ---------------------------------------------------------------------- diff --git a/s2http/src/main/scala/org/apache/s2graph/http/Server.scala b/s2http/src/main/scala/org/apache/s2graph/http/Server.scala index 03802ed..e70a182 100644 --- a/s2http/src/main/scala/org/apache/s2graph/http/Server.scala +++ b/s2http/src/main/scala/org/apache/s2graph/http/Server.scala @@ -19,6 +19,8 @@ package org.apache.s2graph.http +import java.time.Instant + import scala.language.postfixOps import scala.concurrent.{Await, ExecutionContext, Future} import scala.concurrent.duration.Duration @@ -51,9 +53,13 @@ object Server extends App val port = sys.props.get("http.port").fold(8000)(_.toInt) val interface = sys.props.get("http.interface").fold("0.0.0.0")(identity) - val serverStatus = s""" { "port": ${port}, "interface": ${interface}, "started_at": ${System.currentTimeMillis()} }""" + val startAt = System.currentTimeMillis() + + def uptime = System.currentTimeMillis() - startAt + + def serverHealth = s"""{ "port": ${port}, "interface": "${interface}", "started_at": ${Instant.ofEpochMilli(startAt)}, "uptime": "${uptime} millis" """ - val health = HttpResponse(status = StatusCodes.OK, entity = HttpEntity(ContentTypes.`application/json`, serverStatus)) + def health = HttpResponse(status = StatusCodes.OK, entity = HttpEntity(ContentTypes.`application/json`, serverHealth)) // Allows you to determine routes to expose according to external settings. lazy val routes: Route = concat(