Documentation ¶
Index ¶
- Constants
- Variables
- func BodyMw(h http.Handler) http.Handler
- func FilterKeyFound(key, message string, w http.ResponseWriter) (callerShouldReturn bool)
- func FilterSecretKeyFound(key, message string, w http.ResponseWriter) (callerShouldReturn bool)
- func Init(logger *log.Logger, port int)
- func LogMw(h http.Handler) http.Handler
- func NewRouter(routes Routes) *mux.Router
- func Serve()
- type ApiInfo
- type EnvironmentDetails
- type EnvironmentLoadRequest
- type FakeInitRequest
- type Location
- type LoginRequest
- type LoginResponse
- type Middleware
- type Middlewares
- type Route
- type Routes
- type StorePostRequest
Constants ¶
View Source
const ( MimeTypeJSON = "application/json" MimeTypeYAML = "application/x.yaml" )
View Source
const ( API_CALLED_METHOD string = "API call %v, method %v" API_CALLED_PARAM string = "API call with param %s = %v" API_CALLED_BODY string = "API call with body = %v" ENVIRONMENT_CREATED string = "Environment %s created" ENVIRONMENT_UPDATED string = "Environment %s updated" USER_LOGIN string = "User %s logged, token %s" USER_LOGOUT string = "User logged out, token %s" TIME_REPORT string = "execution of (%s:%d) took %s \n" ERROR_NO_BODY string = "Please send a request body" ERROR_CONTENT string = "An error occured %s: %s" VALUE_STORED string = "Value %s:%s has been stored" VALUE_DELETED string = "Value %s has been deleted" )
Variables ¶
Functions ¶
func BodyMw ¶
The BodyMw middleware checks that the request body is not empty and log its content. Its will return an http.StatusBadRequest if the request doesn't have a body
func FilterKeyFound ¶
func FilterKeyFound(key, message string, w http.ResponseWriter) (callerShouldReturn bool)
func FilterSecretKeyFound ¶
func FilterSecretKeyFound(key, message string, w http.ResponseWriter) (callerShouldReturn bool)
Types ¶
type ApiInfo ¶
type ApiInfo struct { Version string Host string Url string EnvironmentDetails *EnvironmentDetails `json:",omitempty"` Err string }
type EnvironmentDetails ¶
type EnvironmentDetails struct {
// contains filtered or unexported fields
}
func (EnvironmentDetails) MarshalJSON ¶
func (r EnvironmentDetails) MarshalJSON() ([]byte, error)
type EnvironmentLoadRequest ¶
type EnvironmentLoadRequest struct {
Location string `json:"location"`
}
type FakeInitRequest ¶
type FakeInitRequest struct {
Location string `json:"location"`
}
type LoginRequest ¶
type LoginResponse ¶
type Middleware ¶
var (
IdMw Middleware = createParamMv("id")
)
type Middlewares ¶
type Middlewares []Middleware
type Route ¶
type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc Middlewares Middlewares }
type StorePostRequest ¶
Click to show internal directories.
Click to hide internal directories.