Guide for creating a Slab server

package com.criteo.slab.example import import import import com.criteo.slab.lib.InMemoryStore import lol.http._ import org.slf4j.LoggerFactory object Launcher { import SimpleBoard._ import private val logger = LoggerFactory.getLogger(this.getClass) def main(args: Array[String]): Unit = { require(args.length == 1, "you must supply a port!") val port = args(0).toInt 

You should provide codec for checked value types for values to be persistent in a store

import InMemoryStore.codec 

Define a value store for uploading and restoring history

implicit val store = new InMemoryStore 

Create a web server


You can define custom routes, Slab web server is built with lolhttp

.withRoutes(stateService => { case GET at "/api/heartbeat" => Ok("ok") case GET at url"/api/boards/$board/status" => stateService .current(URLDecoder.decode(board, "UTF-8")).map(view => Ok( .recover { case NotFoundError(message) => NotFound(message) case e => logger.error(e.getMessage, e) InternalServerError() } }) 

Attach a board to the server


Launch the server at port

.apply(port) } }