HTTP Server

HTTP server is the entry point for Diarkis. The application server connects to HTTP server to retrieve the real-time connection endpoint and encryption keys.
We will be explaining how to write the basic HTTP server code and explain configurations.

HTTP Configurations



The address or hostname for HTTP server.



The port for HTTP server.



If true, HTTP server will bind with the given port only.



If false, real-time communication encryption will be disabled. You must set the same configurations for other servers as well.


The server code

This is the main source file of HTTP server.


package main

import (

func main() {
      rootpath, err := os.Getwd()
      if err != nil {
      log.Setup(fmt.Sprintf("%s/configs/shared/log.json", rootpath))
      // Sets up the internal communication network
      mesh.Setup(fmt.Sprintf("%s/configs/shared/mesh.json", rootpath))
      // This sets up HTTP server as Diarkis cluster entry point
      http.SetupAsAuthServer(fmt.Sprintf("%s/configs/http/main.json", rootpath))
      // Sets up match making with configurations
      matching.Setup(fmt.Sprintf("%s/configs/shared/matching.json", rootpath))
      // All HTTP REST API implementations are exposed by calling cmds.ExposeHTTP()

How To Write Custom HTTP REST EndPoint

Diarkis’ HTTP server allows you to write custom REST endpoints.


package httpcmds

import (

func Expose(rootpath string) {
      // :message is treated as a parameter and the value can be accessed from *http.Params

      http.Get("/hello/:message", handleHello)

func handleHello(res *http.Response, req *http.Request, params *http.Params, next func(error)) {
      message := params.GetAsString("message")
      res.Respond(message, http.Ok)
      // move on to other handlers

Match Making Configurations

HTTP server and TCP and/or UDP server both need to have this configuration in order to use Match Making. 



Ratio of sharded match making data saturation among the HTTP server nodes in percentage: e.i. 30 means 30%

How To Define Match Conditions For Match Making

Diarkis Match Making allows you to define multiple search conditions. Match Making definitions must be defined in HTTP server.

levelAndRank := "levelAndRank"
conds := make(map[string]int)
// Search will be in the range of level 0 to 10, 11 to 20, 21 to 30...
conds["level"] = 10
// Search will be in the range of rank 0 to 50, 51 to 100, 101 to 150...
conds["rank"] = 50
// levelAndRank will search against level and rank within their ranges.
matching.Define(levelAndRank, conds)

How To Define Complex Match Conditions For Match Making

The example below shows how to define compound match conditions to be used by search to match with strict conditions first and less strict conditions if not enough matches are not found. Match Making definitions must be defined in HTTP server.

strict = "strict"
strictConds := make(map[string]int)
strictConds["power"] = 5
strictConds["league"] = 1
// This is the definition of the first strict search condition
matching.Define(strict, strictConds)

lessStrict = "lessStrict"
lessStrictConds := make(map[string]int)
lessStrictConds["power"] = 10
lessStrictConds["league"] = 5
// This is the second definition and it is less strict than the first condition
matching.Define(lessStrict, lessStrictConds)

Auth API

In order to connect to Diarkis server cluster, you must retrieve a connection endpoint from Diarkis HTTP server.

The API is shown below:

GET /auth/<application user ID>


  "WS":"<websocket endpoint address and port>",

  "UDP":"<udp endpoint address and port>",

  "TCP":"<tcp endpoint address and port>"


Metrics API

Diarkis has metrics REST API to see what is going on with your Diarkis application in real-time.  By scraping this API and forwarding the data to analytic tools such as Prometheus + Grafana, Datadog etc, will give you detailed analytic tools immediately.

Prometheus Format:

GET /metrics/prometheus/v/2

JSON Format:

GET /metrics/json

Metrics Data - Prometheus Format

NOTE: There are more metrics data other than shown below.


CCU (Concurrent Users) per node of each protocol.


Inbound packets per node of each protocol.


Outbound packets per node of each protocol.


Inbound internal packets per node of each protocol.


Outbound internal packets per node of each protocol.