srv

package
v0.0.0-...-6991b5a Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package srv provides the HTTP server for the backend.

Index

Constants

View Source
const APIPrefix = "api"

Variables

This section is empty.

Functions

func Handler

func Handler(logger Logger, m *model.Model) http.Handler

func Run

func Run(logger LoggerWithFatal, env Environment, m *model.Model) error

Run is the entry point for this module. It does some preparation and then starts the server.

func Start

func Start(ctx context.Context, logger Logger, m *model.Model, addr string) error

Start starts the server. It blocks and returns an error if the server was not shut down gracefully.

Types

type CaseHandler

type CaseHandler struct {
	Logger Logger
	Model  *model.Model
}

func NewCaseHandler

func NewCaseHandler(logger Logger, m *model.Model) *CaseHandler

func (CaseHandler) NewCase

func (h CaseHandler) NewCase() func(http.ResponseWriter, *http.Request)

func (CaseHandler) RetrieveCases

func (h CaseHandler) RetrieveCases() func(http.ResponseWriter, *http.Request)

func (CaseHandler) ServeHTTP

func (h CaseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Environment

type Environment interface {
	Host() string
	Port() string
}

type Logger

type Logger interface {
	Printf(format string, v ...any)
}

type LoggerWithFatal

type LoggerWithFatal interface {
	Logger
	Fatalf(format string, v ...any)
}

Jump to

Keyboard shortcuts

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