7 |
Welcome to Very Secure Systems Ltd
8 |
The time is {{time}}
9 |
Your browser is {{browser}}
10 |
Here is a (OAuth secured) list of known users (rendered with a Handlebars template)
11 |
Here is the auto-generated remote API documentation (using a OpenApi 3 renderer)
12 |
Here is a secured OpenApi 3 UI for interacting with the API (using a StaticModule)
13 |
Here are some diagnostic endpoints
14 |
Here is the Chaos injection interface for the user directory.
15 |

16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/main/kotlin/verysecuresystems/web/ShowError.kt:
--------------------------------------------------------------------------------
1 | package verysecuresystems.web
2 |
3 | import org.http4k.core.Body
4 | import org.http4k.core.ContentType.Companion.TEXT_HTML
5 | import org.http4k.core.Filter
6 | import org.http4k.core.Response
7 | import org.http4k.core.Status.Companion.SERVICE_UNAVAILABLE
8 | import org.http4k.core.with
9 | import org.http4k.template.TemplateRenderer
10 | import org.http4k.template.ViewModel
11 | import org.http4k.template.viewModel
12 |
13 | /**
14 | * Catch all exceptions and shows a nice HTML page instead of a stacktrace
15 | */
16 | fun ShowError(templates: TemplateRenderer) = Filter { next ->
17 | {
18 | try {
19 | next(it)
20 | } catch (e: Exception) {
21 | Response(SERVICE_UNAVAILABLE).with(Body.viewModel(templates, TEXT_HTML).toLens() of (Error(e)))
22 | }
23 | }
24 | }
25 |
26 | class Error(e: Exception) : ViewModel {
27 | val message = e.localizedMessage
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/resources/functional/WebTest.homepage.approved:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
Welcome to Very Secure Systems Ltd
8 |
The time is 3000-01-01T00:00:00
9 |
Your browser is unknown
10 |
Here is a (OAuth secured) list of known users (rendered with a Handlebars template)
11 |
Here is the auto-generated remote API documentation (using a OpenApi 3 renderer)
12 |
Here is a secured OpenApi 3 UI for interacting with the API (using a StaticModule)
13 |
Here are some diagnostic endpoints
14 |
Here is the Chaos injection interface for the user directory.
15 |

16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/main/kotlin/verysecuresystems/web/ShowIndex.kt:
--------------------------------------------------------------------------------
1 | package verysecuresystems.web
2 |
3 | import org.http4k.core.Method.GET
4 | import org.http4k.core.Response
5 | import org.http4k.core.Status.Companion.OK
6 | import org.http4k.core.then
7 | import org.http4k.routing.bind
8 | import org.http4k.template.TemplateRenderer
9 | import org.http4k.template.ViewModel
10 | import java.time.Clock
11 | import java.time.LocalDateTime
12 | import java.time.format.DateTimeFormatter
13 |
14 | data class Index(val time: String, val browser: String) : ViewModel
15 |
16 | /**
17 | * The root index page of the server, displayed using a ViewModel.
18 | */
19 | fun ShowIndex(clock: Clock, renderer: TemplateRenderer) =
20 | "/" bind GET to SetHtmlContentType.then {
21 | Response(OK).body(
22 | renderer(
23 | Index(LocalDateTime.now(clock).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME), it.header("User-Agent")
24 | ?: "unknown"))
25 | )
26 | }
--------------------------------------------------------------------------------
/src/test/resources/functional/ManageUsersTest.add user.approved:
--------------------------------------------------------------------------------
1 |
2 |
3 |