-
Notifications
You must be signed in to change notification settings - Fork 0
/
IReponseLogger.go
46 lines (32 loc) · 1.42 KB
/
IReponseLogger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package request
import (
"net/http"
)
// IResponseLogger outlines methods for handling logging for API Responses
type IResponseLogger interface {
// HandleError handles errors returned from the service layer and
// calls a api error handler to return the corresponding HTTP response
HandleError(r *Request, w http.ResponseWriter, e error)
// NotImplemented shows a text response for not implemented method (501)
NotImplemented(r *Request, w http.ResponseWriter)
// InternalServerError returns a 500 server error response
InternalServerError(r *Request, w http.ResponseWriter, e error)
// NotFound returns a not-found status
NotFound(r *Request, w http.ResponseWriter)
// BadRequest returns a bad request status (400)
BadRequest(r *Request, w http.ResponseWriter, e error)
// Unauthorized returns an unauthorized status (401)
Unauthorized(r *Request, w http.ResponseWriter)
// Forbidden returns a forbidden status (403)
Forbidden(r *Request, w http.ResponseWriter)
// NoContent returns a noContent status (204)
NoContent(r *Request, w http.ResponseWriter)
// Created returns a created status (201)
Created(r *Request, w http.ResponseWriter)
// JSON Returns an ok status with json-encoded body
JSON(r *Request, w http.ResponseWriter, body interface{})
// HTML Returns an ok status with html body
HTML(r *Request, w http.ResponseWriter, body string)
// OK Returns an ok status
OK(r *Request, w http.ResponseWriter)
}