controller

package
v0.0.0-...-c7180f5 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2019 License: GPL-3.0, GPL-3.0-or-later Imports: 9 Imported by: 0

Documentation

Overview

controller contains structs and methods used to provide endpoints for storing hostdata informations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupRoutesForHostDataController

func SetupRoutesForHostDataController(router *mux.Router, ctrl HostDataControllerInterface)

func WriteAndLogError

func WriteAndLogError(w http.ResponseWriter, statusCode int, err utils.AdvancedError)

WriteAndLogError write the error to the w with the statusCode as statusCode and log the error to the stdout

func WriteJSONResponse

func WriteJSONResponse(w http.ResponseWriter, statusCode int, resp interface{})

WriteJSONResponse write the statuscode and the response to w

Types

type ErrorResponseFE

type ErrorResponseFE struct {
	// Error contains the (generic) class of the error
	Error string
	// ErrorDescription contains detailed informations about the error
	ErrorDescription string
	// File contains the filename of the source code where the error was detected
	SourceFilename string
	// LineNumber contains the number of the line where the error was detected
	LineNumber int
}

ErrorResponseFE is a struct that contains informations about a error

type HostDataController

type HostDataController struct {
	// Config contains the dataservice global configuration
	// TODO: Should be removed?
	Config config.Configuration
	// Service contains the underlying service used to perform various logical and store operations
	Service service.ServiceInterface
}

HostDataController is the struct used to handle the requests from agents and contains the concrete implementation of HostDataControllerInterface

func (*HostDataController) AuthenticateMiddleware

func (this *HostDataController) AuthenticateMiddleware() func(http.Handler) http.Handler

func (*HostDataController) UpdateHostInfo

func (this *HostDataController) UpdateHostInfo(w http.ResponseWriter, r *http.Request)

UpdateHostInfo update the informations about a host using the HostData in the request

type HostDataControllerInterface

type HostDataControllerInterface interface {
	// UpdateHostInfo update the informations about a host using the HostData in the request
	UpdateHostInfo(w http.ResponseWriter, r *http.Request)
	// AuthenticateMiddleware return the middleware used to authenticate users
	AuthenticateMiddleware() func(http.Handler) http.Handler
}

HostDataControllerInterface is a interface that wrap methods used to handle the request for HostData endpoints

Jump to

Keyboard shortcuts

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