api

package
v0.0.0-...-9706718 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package api provides an API server for controlling the Dice core.

Package api provides an API server for controlling the Dice core.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the actual HTTP server exposing a REST API. It will accept requests on the specified TCP address and handles these requests using the provided controller.Controller instance. The listening port has to be secured against remote access.

func NewServer

func NewServer(config ServerConfig, controller *controller.Controller) *Server

NewServer creates a new Server instance and initializes all routes.

func (*Server) Run

func (s *Server) Run() error

Run makes the API server listen on the specified TCP address and accept incoming requests. This function should be called in an extra goroutine since Run is a blocking function.

Unlike ListenAndServe from net/http, Run only returns real errors, meaning that it won't return an error when shutting down.

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown attempts a graceful shutdown. Active connections will not be interrupted until the context used inside Shutdown expires.

type ServerConfig

type ServerConfig struct {
	Address string `json:"address"`
	Logfile string `json:"logfile"`
}

ServerConfig concludes properties that are configurable by the user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL