api

package
v0.0.0-...-f5eeede Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//APIErrorBodyParsing parsing body issue
	APIErrorBodyParsing = 1
	//APIErrorDatabase Database connexion issue
	APIErrorDatabase = 2
	//APIErrorInvalidValue invalid parameter
	APIErrorInvalidValue = 3

	//URLNotes
	URLNotes = "/notes"
)

Variables

This section is empty.

Functions

func InitAPI

func InitAPI(ip, port string)

InitAPI start API connection

func NewError

func NewError(text string) error

NewError raise an error

Types

type API

type API struct {
	APIIP    string
	APIPort  string
	Database *core.Database
}

API description of the web API

func (*API) SendError

func (api *API) SendError(w http.ResponseWriter, errorCode int, message string, httpStatus int)

SendError standardization of API Error message

func (*API) SetDefaultHeader

func (api *API) SetDefaultHeader(w http.ResponseWriter, req *http.Request)

SetDefaultHeader set http headers

type APIError

type APIError struct {
	Code    int    `json:"code"` //errorCode
	Message string `json:"message"`
}

APIError Message error code

Jump to

Keyboard shortcuts

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