Skip to content

Commit adce1f3

Browse files
committed
Updated comments, comment format.
1 parent 023e70d commit adce1f3

File tree

7 files changed

+159
-68
lines changed

7 files changed

+159
-68
lines changed

.gitignore

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,87 @@
1-
.DS_Store
1+
# Created by https://www.gitignore.io/api/go,osx,linux,windows
2+
3+
### Go ###
4+
# Binaries for programs and plugins
5+
*.exe
6+
*.dll
7+
*.so
8+
*.dylib
9+
10+
# Test binary, build with `go test -c`
11+
*.test
12+
13+
# Output of the go coverage tool, specifically when used with LiteIDE
14+
*.out
15+
16+
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
17+
.glide/
18+
19+
# Golang project vendor packages which should be ignored
20+
vendor/
21+
22+
### Linux ###
23+
*~
24+
25+
# temporary files which can be created if a process still has a handle open of a deleted file
26+
.fuse_hidden*
27+
28+
# KDE directory preferences
29+
.directory
30+
31+
# Linux trash folder which might appear on any partition or disk
32+
.Trash-*
33+
34+
# .nfs files are created when an open file is removed but is still being accessed
35+
.nfs*
36+
37+
### OSX ###
38+
*.DS_Store
39+
.AppleDouble
40+
.LSOverride
41+
42+
# Icon must end with two \r
43+
Icon
44+
45+
# Thumbnails
46+
._*
47+
48+
# Files that might appear in the root of a volume
49+
.DocumentRevisions-V100
50+
.fseventsd
51+
.Spotlight-V100
52+
.TemporaryItems
53+
.Trashes
54+
.VolumeIcon.icns
55+
.com.apple.timemachine.donotpresent
56+
57+
# Directories potentially created on remote AFP share
58+
.AppleDB
59+
.AppleDesktop
60+
Network Trash Folder
61+
Temporary Items
62+
.apdisk
63+
64+
### Windows ###
65+
# Windows thumbnail cache files
66+
Thumbs.db
67+
ehthumbs.db
68+
ehthumbs_vista.db
69+
70+
# Folder config file
71+
Desktop.ini
72+
73+
# Recycle Bin used on file shares
74+
$RECYCLE.BIN/
75+
76+
# Windows Installer files
77+
*.cab
78+
*.msi
79+
*.msm
80+
*.msp
81+
82+
# Windows shortcuts
83+
*.lnk
84+
85+
# End of https://www.gitignore.io/api/go,osx,linux,windows
86+
87+
.vscode

config.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ import (
77
"strconv"
88
)
99

10-
// Config struct for reading app's configuration from json file
10+
// Config is used for reading app's configuration from json file
1111
type Config struct {
12-
//Env is the deployment environment
12+
// Env is the deployment environment
1313
Env string `json:"environment"`
14-
//Host is the host on which the server is listening
14+
// Host is the host on which the server is listening
1515
Host string `json:"host,omitempty"`
16-
//Port is the port number where the server has to listen for the HTTP requests
16+
// Port is the port number where the server has to listen for the HTTP requests
1717
Port string `json:"port"`
1818

19-
//CertFile is the TLS/SSL certificate file path, required for HTTPS
19+
// CertFile is the TLS/SSL certificate file path, required for HTTPS
2020
CertFile string `json:"certFile,omitempty"`
21-
//KeyFile is the filepath of private key of the certificate
21+
// KeyFile is the filepath of private key of the certificate
2222
KeyFile string `json:"keyFile,omitempty"`
23-
//HTTPSPort is the port number where the server has to listen for the HTTP requests
23+
// HTTPSPort is the port number where the server has to listen for the HTTP requests
2424
HTTPSPort string `json:"httpsPort,omitempty"`
25-
//HTTPSOnly if true will enable HTTPS server alone
25+
// HTTPSOnly if true will enable HTTPS server alone
2626
HTTPSOnly bool `json:"httpsOnly,omitempty"`
2727

28-
//TemplatesBasePath is the base path where all the HTML templates are located
28+
// TemplatesBasePath is the base path where all the HTML templates are located
2929
TemplatesBasePath string `json:"templatePath,omitempty"`
3030

3131
// Data holds the full json config file data as bytes
@@ -61,7 +61,7 @@ func (cfg *Config) Validate() {
6161
}
6262
}
6363

64-
//Globals struct to hold configurations which are shared with all the request handlers via context.
64+
// Globals struct to hold configurations which are shared with all the request handlers via context.
6565
type Globals struct {
6666

6767
// All the app configurations
@@ -80,7 +80,7 @@ func (g *Globals) Add(key string, data interface{}) {
8080
g.App[key] = data
8181
}
8282

83-
//Init initializes the Context and set appropriate values
83+
// Init initializes the Context and set appropriate values
8484
func (g *Globals) Init(cfg *Config, tpls map[string]*htpl.Template) {
8585
g.App = make(map[string]interface{})
8686
g.Templates = make(map[string]*htpl.Template)

errors.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ import (
66
)
77

88
const (
9-
//C001 Error Code 1
9+
// C001 Error Code 1
1010
C001 = "Invalid number of arguments provided"
11-
//C002 Error Code 2
11+
// C002 Error Code 2
1212
C002 = "Could not unmarshal JSON config file"
13-
//C003 Error Code 3
13+
// C003 Error Code 3
1414
C003 = "App environment not provided in config file, accepted values are `production` or `development`"
15-
//C004 Error Code 4
15+
// C004 Error Code 4
1616
C004 = "App port not provided in config file"
17-
//C005 Error Code 5
17+
// C005 Error Code 5
1818
C005 = "Invalid JSON"
1919
)
2020

21-
//Errors struct is the custom error for webgo error handling
21+
// Errors is the custom error for webgo error handling
2222
type Errors struct {
2323
msg string
2424
}
@@ -27,7 +27,7 @@ func (e *Errors) Error() string {
2727
return e.msg
2828
}
2929

30-
//New returns a new instance of Errors struct
30+
// New returns a new instance of Errors struct
3131
func New(str string) *Errors {
3232
return &Errors{
3333
msg: str,

middlewares.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"net/http"
55
)
66

7-
//Middlewares has all the default middlewares provided by webgo
7+
// Middlewares has all the default middlewares provided by webgo
88
type Middlewares struct{}
99

1010
const (
@@ -18,7 +18,7 @@ const (
1818
allowHeaders = "Accept,Content-Type,Content-Length,Accept-Encoding,Access-Control-Request-Headers,"
1919
)
2020

21-
//Cors is a basic Cors middleware definition.
21+
// Cors is a basic Cors middleware definition.
2222
func (m *Middlewares) Cors(rw http.ResponseWriter, req *http.Request) {
2323
// Set response appropriate headers required for CORS
2424
rw.Header().Set(headerOrigin, req.Header.Get(headerGetOrigin))
@@ -29,7 +29,7 @@ func (m *Middlewares) Cors(rw http.ResponseWriter, req *http.Request) {
2929
rw.Header().Set(headerAllowHeaders, allowHeaders+req.Header.Get(headerReqHeaders))
3030
}
3131

32-
//CorsOptions is a cors middleware just for Options request - adding this helped remove the request method check (an `if` block to check the request type) from Cors middleware
32+
// CorsOptions is a cors middleware just for Options request - adding this helped remove the request method check (an `if` block to check the request type) from Cors middleware
3333
func (m *Middlewares) CorsOptions(rw http.ResponseWriter, req *http.Request) {
3434
// Set response appropriate headers required for CORS
3535
rw.Header().Set(headerOrigin, req.Header.Get(headerGetOrigin))

responses.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"net/http"
88
)
99

10-
//ErrorData used to render the error page
10+
// ErrorData used to render the error page
1111
type ErrorData struct {
1212
ErrCode int
1313
ErrDescription string
@@ -24,24 +24,25 @@ type errOutput struct {
2424
}
2525

2626
const (
27-
//HeaderContentType is the key for mentioning the response header content type
27+
// HeaderContentType is the key for mentioning the response header content type
2828
HeaderContentType = "Content-Type"
29-
//JSONContentType is the MIME type when the response is JSON
29+
// JSONContentType is the MIME type when the response is JSON
3030
JSONContentType = "application/json"
31-
//HTMLContentType is the MIME type when the response is HTML
31+
// HTMLContentType is the MIME type when the response is HTML
3232
HTMLContentType = "text/html; charset=UTF-8"
3333

34-
//ErrInternalServer to send when there's an internal server error
34+
// ErrInternalServer to send when there's an internal server error
3535
ErrInternalServer = "Internal server error."
3636
)
3737

38-
//SendHeader is used to send only a response header, i.e no response body
38+
// SendHeader is used to send only a response header, i.e no response body
3939
func SendHeader(w http.ResponseWriter, rCode int) {
4040
w.WriteHeader(rCode)
4141
fmt.Fprint(w)
4242
}
4343

44-
//Send is used to send a completely custom response without wrapping in the `{data: <data>, status: <int>` struct
44+
// Send sends a completely custom response without wrapping in the
45+
// `{data: <data>, status: <int>` struct
4546
func Send(w http.ResponseWriter, contentType string, data interface{}, rCode int) {
4647
w.Header().Set(HeaderContentType, contentType)
4748
w.WriteHeader(rCode)
@@ -55,7 +56,7 @@ func Send(w http.ResponseWriter, contentType string, data interface{}, rCode int
5556
}
5657
}
5758

58-
//SendResponse is used to respond to any request (JSON response) based on the code, data etc.
59+
// SendResponse is used to respond to any request (JSON response) based on the code, data etc.
5960
func SendResponse(w http.ResponseWriter, data interface{}, rCode int) {
6061
w.Header().Set(HeaderContentType, JSONContentType)
6162

@@ -76,7 +77,7 @@ func SendResponse(w http.ResponseWriter, data interface{}, rCode int) {
7677
}
7778
}
7879

79-
//SendError is used to respond to any request with an error
80+
// SendError is used to respond to any request with an error
8081
func SendError(w http.ResponseWriter, data interface{}, rCode int) {
8182
w.Header().Set(HeaderContentType, JSONContentType)
8283

0 commit comments

Comments
 (0)