Documentation ¶
Overview ¶
Package api must be documented
Index ¶
- func APIError(msg string) apiError
- func APIErrorFromError(e error) apiError
- func APIErrorf(format string, a ...interface{}) apiError
- func ConfigGetHandler(w http.ResponseWriter, r *http.Request)
- func ConfigPostHandler(w http.ResponseWriter, r *http.Request)
- func DashboardHandler(w http.ResponseWriter, r *http.Request)
- func DevicesHandler(w http.ResponseWriter, r *http.Request)
- func InitConfig() error
- func InitLogger()
- func LoggingMiddleware(h http.Handler) http.Handler
- func PingHandler(w http.ResponseWriter, r *http.Request)
- func RunHandler(w http.ResponseWriter, r *http.Request)
- func Serve() error
- func StatsHandler(w http.ResponseWriter, r *http.Request)
- type BadMethodHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 LoggingMiddleware ¶
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)