Skip to content

Commit

Permalink
Fix golint
Browse files Browse the repository at this point in the history
Former-commit-id: 098ac8e0e91e063d905d67c95b16f344892118a6 [formerly 098ac8e0e91e063d905d67c95b16f344892118a6 [formerly 76fb4f9]]
Former-commit-id: 2aefd4804c360bed4e73dec685a5cc52f10684b2
Former-commit-id: 3bb4cc4
  • Loading branch information
sufuf3 committed Jul 24, 2018
1 parent 6f3185e commit 9ca55fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/net/http/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func TestCompositeServiceHandler(t *testing.T) {
data := 0
var handler = func(*web.NativeContext) {
data += 1
data++
}

req, err := http.NewRequest("POST", "http://here.com/v1/signin", nil)
Expand All @@ -27,7 +27,7 @@ func TestCompositeServiceHandler(t *testing.T) {
func TestRESTfulServiceHandler(t *testing.T) {
data := 0
var handler = func(*web.Context) {
data += 1
data++
}

routeHandler := RESTfulServiceHandler(nil, handler)
Expand Down
24 changes: 12 additions & 12 deletions src/net/http/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
)

// The Structure to contain the Error Message from the HTTP response
// ErrorPayload is the Structure to contain the Error Message from the HTTP response
// Contains the Error Messagess (At most two errors)
type ErrorPayload struct {
XMLName xml.Name `json:"-" xml:"response"`
Expand All @@ -15,7 +15,7 @@ type ErrorPayload struct {
PreviousMessage string `json:"previousMessage,omitempty" xml:"previousMessage,omitempty"`
}

// Return the ErrorPayload message according the parameters (errors)
// NewErrorPayload will return the ErrorPayload message according the parameters (errors)
// The ErrorPayload contains at most error messages
func NewErrorPayload(errs ...error) ErrorPayload {
payload := ErrorPayload{Error: true}
Expand All @@ -30,7 +30,7 @@ func NewErrorPayload(errs ...error) ErrorPayload {
return payload
}

// The function to get the error from the request and ErrorPayload
// EncodeErrorPayload is the function to get the error from the request and ErrorPayload
// It should contains the errorType and error content
func EncodeErrorPayload(req *http.Request, payload ErrorPayload) (out []byte, contentType string, encErr error) {
contentType = req.Header.Get("content-type")
Expand All @@ -48,7 +48,7 @@ func EncodeErrorPayload(req *http.Request, payload ErrorPayload) (out []byte, co
return out, contentType, encErr
}

// Write the error status and error code to the http request and return the written byte count of the http request
// WriteStatusAndError will write the error status and error code to the http request and return the written byte count of the http request
func WriteStatusAndError(req *http.Request, resp http.ResponseWriter, status int, errs ...error) (int, error) {
payload := NewErrorPayload(errs...)
out, contentType, encErr := EncodeErrorPayload(req, payload)
Expand All @@ -62,42 +62,42 @@ func WriteStatusAndError(req *http.Request, resp http.ResponseWriter, status int
return resp.Write(out)
}

// Set the status code http.StatusForbidden to the HTTP response message
// Forbidden will set the status code http.StatusForbidden to the HTTP response message
func Forbidden(req *http.Request, resp http.ResponseWriter, errs ...error) (int, error) {
return WriteStatusAndError(req, resp, http.StatusForbidden, errs...)
}

// Set the status code http.StatusBadRequest to the HTTP response message
// BadRequest will set the status code http.StatusBadRequest to the HTTP response message
func BadRequest(req *http.Request, resp http.ResponseWriter, errs ...error) (int, error) {
return WriteStatusAndError(req, resp, http.StatusBadRequest, errs...)
}

// Set the status code http.StatusOK to the HTTP response message
// OK will set the status code http.StatusOK to the HTTP response message
func OK(req *http.Request, resp http.ResponseWriter, errs ...error) (int, error) {
return WriteStatusAndError(req, resp, http.StatusOK, errs...)
}

// Set the status code http.StatusNotFound to the HTTP response message
// NotFound will set the status code http.StatusNotFound to the HTTP response message
func NotFound(req *http.Request, resp http.ResponseWriter, errs ...error) (int, error) {
return WriteStatusAndError(req, resp, http.StatusNotFound, errs...)
}

// Set the status code http.StatusUnauthorized to the HTTP response message
// Unauthorized will set the status code http.StatusUnauthorized to the HTTP response message
func Unauthorized(req *http.Request, resp http.ResponseWriter, errs ...error) (int, error) {
return WriteStatusAndError(req, resp, http.StatusUnauthorized, errs...)
}

// Set the status code http.StatusInternalServerError to the HTTP response message
// InternalServerError will set the status code http.StatusInternalServerError to the HTTP response message
func InternalServerError(req *http.Request, resp http.ResponseWriter, errs ...error) (int, error) {
return WriteStatusAndError(req, resp, http.StatusInternalServerError, errs...)
}

// Set the status code http.StatusConflict to the HTTP response message
// Conflict will set the status code http.StatusConflict to the HTTP response message
func Conflict(req *http.Request, resp http.ResponseWriter, errs ...error) (int, error) {
return WriteStatusAndError(req, resp, http.StatusConflict, errs...)
}

// Set the status code http.StatusUnprocessableEntity to the HTTP response message
// UnprocessableEntity will set the status code http.StatusUnprocessableEntity to the HTTP response message
func UnprocessableEntity(req *http.Request, resp http.ResponseWriter, errs ...error) (int, error) {
return WriteStatusAndError(req, resp, http.StatusUnprocessableEntity, errs...)
}

0 comments on commit 9ca55fe

Please sign in to comment.