1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-21 14:19:43 +02:00

Go fmt and linting issues

This commit is contained in:
Harvey Kandola 2016-10-17 14:17:54 -07:00
parent cf9de30a23
commit 7cd1c2f80c
5 changed files with 22 additions and 2 deletions

View file

@ -28,6 +28,8 @@ import (
) )
var port, certFile, keyFile, forcePort2SSL string var port, certFile, keyFile, forcePort2SSL string
// Product details app edition and version
var Product core.ProdInfo var Product core.ProdInfo
func init() { func init() {

View file

@ -1,11 +1,11 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved. // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
// //
// This software (Documize Community Edition) is licensed under // This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
// //
// You can operate outside the AGPL restrictions by purchasing // You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license // Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>. // by contacting <sales@documize.com>.
// //
// https://documize.com // https://documize.com

View file

@ -18,6 +18,7 @@ import (
"github.com/documize/community/core/api/util" "github.com/documize/community/core/api/util"
) )
// SetupPersister prepares context for database activity.
func SetupPersister() (*Persister, error) { func SetupPersister() (*Persister, error) {
var err error var err error
c := Context{ c := Context{
@ -40,6 +41,7 @@ func SetupPersister() (*Persister, error) {
return p, err return p, err
} }
// SetupOrganization creates "tenant" record in database.
func (p *Persister) SetupOrganization(company, title, message, domain, email string) (entity.Organization, error) { func (p *Persister) SetupOrganization(company, title, message, domain, email string) (entity.Organization, error) {
org := entity.Organization{ org := entity.Organization{
BaseEntity: entity.BaseEntity{RefID: p.Context.OrgID}, BaseEntity: entity.BaseEntity{RefID: p.Context.OrgID},

View file

@ -19,6 +19,7 @@ import (
"github.com/documize/community/core/log" "github.com/documize/community/core/log"
) )
// WritePayloadError error handling
func WritePayloadError(w http.ResponseWriter, method string, err error) { func WritePayloadError(w http.ResponseWriter, method string, err error) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
@ -27,6 +28,7 @@ func WritePayloadError(w http.ResponseWriter, method string, err error) {
log.Error(fmt.Sprintf("Unable to decode HTML request body for method %s", method), err) log.Error(fmt.Sprintf("Unable to decode HTML request body for method %s", method), err)
} }
// WriteTransactionError error handling
func WriteTransactionError(w http.ResponseWriter, method string, err error) { func WriteTransactionError(w http.ResponseWriter, method string, err error) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
@ -35,6 +37,7 @@ func WriteTransactionError(w http.ResponseWriter, method string, err error) {
log.Error(fmt.Sprintf("Unable to get database transaction for method %s", method), err) log.Error(fmt.Sprintf("Unable to get database transaction for method %s", method), err)
} }
// WriteMissingDataError error handling
func WriteMissingDataError(w http.ResponseWriter, method, parameter string) { func WriteMissingDataError(w http.ResponseWriter, method, parameter string) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
@ -43,6 +46,7 @@ func WriteMissingDataError(w http.ResponseWriter, method, parameter string) {
log.Info(fmt.Sprintf("Missing data %s for method %s", parameter, method)) log.Info(fmt.Sprintf("Missing data %s for method %s", parameter, method))
} }
// WriteNotFoundError error handling
func WriteNotFoundError(w http.ResponseWriter, method string, id string) { func WriteNotFoundError(w http.ResponseWriter, method string, id string) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusNotFound) w.WriteHeader(http.StatusNotFound)
@ -51,6 +55,7 @@ func WriteNotFoundError(w http.ResponseWriter, method string, id string) {
log.Info(fmt.Sprintf("Not found ID %s for method %s", id, method)) log.Info(fmt.Sprintf("Not found ID %s for method %s", id, method))
} }
// WriteGeneralSQLError error handling
func WriteGeneralSQLError(w http.ResponseWriter, method string, err error) { func WriteGeneralSQLError(w http.ResponseWriter, method string, err error) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
@ -59,6 +64,7 @@ func WriteGeneralSQLError(w http.ResponseWriter, method string, err error) {
log.Error(fmt.Sprintf("General SQL error for method %s", method), err) log.Error(fmt.Sprintf("General SQL error for method %s", method), err)
} }
// WriteJSONMarshalError error handling
func WriteJSONMarshalError(w http.ResponseWriter, method, entity string, err error) { func WriteJSONMarshalError(w http.ResponseWriter, method, entity string, err error) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
@ -67,6 +73,7 @@ func WriteJSONMarshalError(w http.ResponseWriter, method, entity string, err err
log.Error(fmt.Sprintf("Failed to JSON marshal %s for method %s", entity, method), err) log.Error(fmt.Sprintf("Failed to JSON marshal %s for method %s", entity, method), err)
} }
// WriteServerError error handling
func WriteServerError(w http.ResponseWriter, method string, err error) { func WriteServerError(w http.ResponseWriter, method string, err error) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
@ -75,6 +82,7 @@ func WriteServerError(w http.ResponseWriter, method string, err error) {
log.Error(fmt.Sprintf("Internal server error for method %s", method), err) log.Error(fmt.Sprintf("Internal server error for method %s", method), err)
} }
// WriteDuplicateError error handling
func WriteDuplicateError(w http.ResponseWriter, method, entity string) { func WriteDuplicateError(w http.ResponseWriter, method, entity string) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusConflict) w.WriteHeader(http.StatusConflict)
@ -83,6 +91,7 @@ func WriteDuplicateError(w http.ResponseWriter, method, entity string) {
log.Info(fmt.Sprintf("Duplicate %s record detected for method %s", entity, method)) log.Info(fmt.Sprintf("Duplicate %s record detected for method %s", entity, method))
} }
// WriteUnauthorizedError error handling
func WriteUnauthorizedError(w http.ResponseWriter) { func WriteUnauthorizedError(w http.ResponseWriter) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusUnauthorized) w.WriteHeader(http.StatusUnauthorized)
@ -90,6 +99,7 @@ func WriteUnauthorizedError(w http.ResponseWriter) {
log.IfErr(err) log.IfErr(err)
} }
// WriteForbiddenError error handling
func WriteForbiddenError(w http.ResponseWriter) { func WriteForbiddenError(w http.ResponseWriter) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusForbidden) w.WriteHeader(http.StatusForbidden)
@ -97,6 +107,7 @@ func WriteForbiddenError(w http.ResponseWriter) {
log.IfErr(err) log.IfErr(err)
} }
// WriteBadRequestError error handling
func WriteBadRequestError(w http.ResponseWriter, method, message string) { func WriteBadRequestError(w http.ResponseWriter, method, message string) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
@ -105,6 +116,7 @@ func WriteBadRequestError(w http.ResponseWriter, method, message string) {
log.Info(fmt.Sprintf("Bad Request %s for method %s", message, method)) log.Info(fmt.Sprintf("Bad Request %s for method %s", message, method))
} }
// WriteSuccessBytes dumps bytes to HTTP response
func WriteSuccessBytes(w http.ResponseWriter, data []byte) { func WriteSuccessBytes(w http.ResponseWriter, data []byte) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
@ -112,6 +124,7 @@ func WriteSuccessBytes(w http.ResponseWriter, data []byte) {
log.IfErr(err) log.IfErr(err)
} }
// WriteSuccessString writes string to HTTP response
func WriteSuccessString(w http.ResponseWriter, data string) { func WriteSuccessString(w http.ResponseWriter, data string) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
@ -119,6 +132,7 @@ func WriteSuccessString(w http.ResponseWriter, data string) {
log.IfErr(err) log.IfErr(err)
} }
// WriteSuccessEmptyJSON writes empty JSON HTTP response
func WriteSuccessEmptyJSON(w http.ResponseWriter) { func WriteSuccessEmptyJSON(w http.ResponseWriter) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
@ -126,6 +140,7 @@ func WriteSuccessEmptyJSON(w http.ResponseWriter) {
log.IfErr(err) log.IfErr(err)
} }
// WriteMarshalError error handling
func WriteMarshalError(w http.ResponseWriter, err error) { func WriteMarshalError(w http.ResponseWriter, err error) {
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)

View file

@ -98,6 +98,7 @@ func Asset(location string) ([]byte, error) {
return Embed.Asset(location) return Embed.Asset(location)
} }
// AssetDir returns web app "assets" folder.
func AssetDir(dir string) ([]string, error) { func AssetDir(dir string) ([]string, error) {
return Embed.AssetDir(dir) return Embed.AssetDir(dir)
} }