Documentation ¶
Index ¶
- Constants
- func AddRoute(verb string, path string, handler Handler)
- func CreateID() uuid.UUID
- func Deserialize(request Request, object interface{}) error
- func ExecuteTestRequest(t *testing.T, verb string, path string, body string, funcHandler Handler) (*http.Request, *httptest.ResponseRecorder)
- func GetTestRequest(t *testing.T, verb string, path string, body string) (*http.Request, *httptest.ResponseRecorder)
- func Handle(w http.ResponseWriter, object Entity, sql string, params ...interface{})
- func HandleBadRequestErr(w http.ResponseWriter, err error)
- func Map(entity Entity, row *sql.Row) error
- func ReturnOne(entity Entity, sql string, args ...interface{}) error
- func RunSQL(sql string, args ...interface{}) (*sql.Row, error)
- func Serialize(data interface{}) ([]byte, error)
- func Serve(w http.ResponseWriter, r *http.Request)
- func WriteErrorToResponse(w http.ResponseWriter, code int)
- type Entity
- type Error
- type ErrorBody
- type Handler
- type LogEntry
- type Request
- type Response
- type Route
Constants ¶
View Source
const ( // DuplicateError record in DB DuplicateError = 409 // InternalError error (Default) InternalError = 500 )
View Source
const ( //DEBUG level DEBUG = "DEBUG" //INFO level INFO = "INFO" //WARN level WARN = "WARN" //ERROR level ERROR = "ERROR" )
Variables ¶
This section is empty.
Functions ¶
func Deserialize ¶
Deserialize JSON byte array to an object
func ExecuteTestRequest ¶
func ExecuteTestRequest(t *testing.T, verb string, path string, body string, funcHandler Handler) (*http.Request, *httptest.ResponseRecorder)
ExecuteTestRequest against the test server
func GetTestRequest ¶
func GetTestRequest(t *testing.T, verb string, path string, body string) (*http.Request, *httptest.ResponseRecorder)
GetTestRequest creates a request for execution
func Handle ¶
func Handle(w http.ResponseWriter, object Entity, sql string, params ...interface{})
Handle processes a HTTP request
func HandleBadRequestErr ¶
func HandleBadRequestErr(w http.ResponseWriter, err error)
HandleBadRequestErr handles a bad request from the client
func Serve ¶
func Serve(w http.ResponseWriter, r *http.Request)
Serve handle a request and using the router redirects the traffic
func WriteErrorToResponse ¶
func WriteErrorToResponse(w http.ResponseWriter, code int)
WriteErrorToResponse writes in a consistent way
Types ¶
type Handler ¶
type Handler func(w http.ResponseWriter, r *http.Request)
Handler is a delegate to concrete handler
type LogEntry ¶
type LogEntry struct { Level string `json:"level"` Action string `json:"action"` Message string `json:"message,omitempty"` Map map[string]string `json:"data,omitempty"` Error error `json:"error,omitempty"` }
LogEntry represents an entry to log with message
Click to show internal directories.
Click to hide internal directories.