api

package
v1.3.2-0...-bd77634 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package api must be documented

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIError

func APIError(msg string) apiError

APIError inits a new error from a string message

func APIErrorFromError

func APIErrorFromError(e error) apiError

APIErrorFromMsg generates the error from an input error message

func APIErrorf

func APIErrorf(format string, a ...interface{}) apiError

APIErrorf inits a new error with string formatting support

func ConfigGetHandler

func ConfigGetHandler(w http.ResponseWriter, r *http.Request)

ConfigGetHandler returns the current config

@Summary Get the config of the IDS @Description You can fetch the netspot config through this endpoint @Accept json @Produce json @Success 200 {object} string "Acknowledge message" @Failure 400 {object} apiError "Error message" @Failure 405 {object} apiError "Error message" @Failure 500 {object} apiError "Error message" @Router /config [get]

func ConfigPostHandler

func ConfigPostHandler(w http.ResponseWriter, r *http.Request)

ConfigPostHandler update the IDS config

@Summary Update the config of the IDS @Description You can update the netspot config through this endpoint @Accept json @Produce plain,json @Param config body map[string]string true "Input config" @Success 201 {string} string "Acknowledge message" @Failure 400 {object} apiError "Error message" @Failure 405 {object} apiError "Error message" @Failure 500 {object} apiError "Error message" @Router /config [post]

func DashboardHandler

func DashboardHandler(w http.ResponseWriter, r *http.Request)

DashboardHandler serves the dashboard

func DevicesHandler

func DevicesHandler(w http.ResponseWriter, r *http.Request)

DevicesHandler returns the list of available interfaces

@Summary List the available devices @Description This returns the list of the network interfaces that can be monitored @Accept json @Produce json @Success 200 {array} string "list of the available devices" @Failure 500 {object} apiError "error message" @Router /devices [get]

func InitConfig

func InitConfig() error

InitConfig prepare the API according to the config file In particular, it initializes the server but does not start to listen

func InitLogger

func InitLogger()

InitLogger initialize the sublogger for API

func LoggingMiddleware

func LoggingMiddleware(h http.Handler) http.Handler

LoggingMiddleware logs the incoming HTTP request & its duration.

func PingHandler

func PingHandler(w http.ResponseWriter, r *http.Request)

PingHandler responds to ping requests

@Summary Server healthcheck @Description This endpoints basically aims to check if the server is up @Accept json @Success 200 @Failure 405 {object} apiError "Error message" @Router /ping [get]

func RunHandler

func RunHandler(w http.ResponseWriter, r *http.Request)

RunHandler manages start/stop actions

@Summary Manage the IDS status @Description Use this path to start/stop the IDS @Accept json @Produce json @Param action body string false "the action to perform" Enums("start", "stop") @Success 200 {string} string "Comment about the action performed" @Failure 400 {object} apiError "Error message" @Router /run [post]

func Serve

func Serve() error

@title Netspot API @version 2.1.1 @description Netspot as a service @termsOfService http://swagger.io/terms/ @contact.name API Support @contact.email asr@nabla.ovh @license.name GPLv3 @license.url https://www.gnu.org/licenses/gpl-3.0.en.html @host localhost:11000 @BasePath /api @Schemes http

func StatsHandler

func StatsHandler(w http.ResponseWriter, r *http.Request)

StatsHandler returns the list of the available stats along with their description

@Summary List the available statistics @Description This returns the list of the statistics than can be loaded @Accept json @Produce json @Header 200 {string} Content-Type "application/json" @Success 200 {object} map[string]string "Available statistics along with their description" @Failure 500 {object} apiError "error message" @Router /stats [get]

Types

type BadMethodHandler

type BadMethodHandler struct{}

BadMethodHandler catches requests with Bad methods

func (BadMethodHandler) ServeHTTP

func (b BadMethodHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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