Add missing comments
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Constants for error reasons
|
||||||
const (
|
const (
|
||||||
ResourceItemNotFound = "Resource Item Not Found"
|
ResourceItemNotFound = "Resource Item Not Found"
|
||||||
NonIntegerValue = "Non Integer Value"
|
NonIntegerValue = "Non Integer Value"
|
||||||
|
|||||||
@@ -27,8 +27,10 @@ type safeHandlerMap struct {
|
|||||||
m *sync.RWMutex
|
m *sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Singleton containing all current handlers as a safeHandlerMap
|
||||||
var Handlers = New()
|
var Handlers = New()
|
||||||
|
|
||||||
|
// New creates a read-to-use safeHandlerMap
|
||||||
func New() safeHandlerMap {
|
func New() safeHandlerMap {
|
||||||
return safeHandlerMap{
|
return safeHandlerMap{
|
||||||
hs: make(map[string]*model.Handler),
|
hs: make(map[string]*model.Handler),
|
||||||
|
|||||||
@@ -5,10 +5,13 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// A ServerErrMessage represents the reason why the error happened
|
||||||
type ServerErrMessage struct {
|
type ServerErrMessage struct {
|
||||||
Reason string `json:"reason"`
|
Reason string `json:"reason"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteErrorResponse writes the error JSON body to the provided http.ResponseWriter,
|
||||||
|
// after setting the appropiate Content-Type header
|
||||||
func WriteErrorResponse(statusCode int, reasonMsg string, res http.ResponseWriter) {
|
func WriteErrorResponse(statusCode int, reasonMsg string, res http.ResponseWriter) {
|
||||||
respBody := ServerErrMessage{}
|
respBody := ServerErrMessage{}
|
||||||
respBody.Reason = reasonMsg
|
respBody.Reason = reasonMsg
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ import (
|
|||||||
"github.com/BBVA/kapow/internal/server/user/mux"
|
"github.com/BBVA/kapow/internal/server/user/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Server is a singleton that stores the http.Server for the user package
|
||||||
var Server = http.Server{
|
var Server = http.Server{
|
||||||
Handler: mux.New(),
|
Handler: mux.New(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run finishes configuring Server and runs ListenAndServe on it
|
||||||
func Run(bindAddr string) {
|
func Run(bindAddr string) {
|
||||||
Server = http.Server{
|
Server = http.Server{
|
||||||
Addr: bindAddr,
|
Addr: bindAddr,
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// An Output represents the execution context,
|
||||||
|
// meaning the command line and the environment
|
||||||
type Output struct {
|
type Output struct {
|
||||||
Cmdline []string `json:"cmdline"`
|
Cmdline []string `json:"cmdline"`
|
||||||
Env map[string]string `json:"env"`
|
Env map[string]string `json:"env"`
|
||||||
|
|||||||
Reference in New Issue
Block a user