mirror of
https://github.com/dcarrillo/whatismyip.git
synced 2025-07-01 12:49:27 +00:00
Add CI and go-report badges. Add comments to make golint happy
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
package core
|
||||
|
||||
// Version to be defined on build time
|
||||
var Version = "tobedefined"
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// HeadersToSortedString shorts and dumps http.Header to a string separated by \n
|
||||
func HeadersToSortedString(headers http.Header) string {
|
||||
var output string
|
||||
|
||||
@ -31,6 +32,7 @@ func HeadersToSortedString(headers http.Header) string {
|
||||
return output
|
||||
}
|
||||
|
||||
// GetLogFormatter returns our custom log format
|
||||
func GetLogFormatter(param gin.LogFormatterParams) string {
|
||||
return fmt.Sprintf("%s - [%s] \"%s %s %s\" %d %d %d %s \"%s\" \"%s\" \"%s\"\n",
|
||||
param.ClientIP,
|
||||
@ -57,9 +59,8 @@ func normalizeLog(log interface{}) interface{} {
|
||||
case []string:
|
||||
if len(v) == 0 {
|
||||
return "-"
|
||||
} else {
|
||||
return strings.Join(v, ", ")
|
||||
}
|
||||
return strings.Join(v, ", ")
|
||||
}
|
||||
|
||||
return log
|
||||
|
@ -33,7 +33,10 @@ type settings struct {
|
||||
|
||||
const defaultAddress = ":8080"
|
||||
|
||||
// ErrVersion is the custom error triggered when -version flag is passed
|
||||
var ErrVersion = errors.New("setting: version requested")
|
||||
|
||||
// App is the var with the parsed settings
|
||||
var App = settings{
|
||||
// hard-coded for the time being
|
||||
Server: serverSettings{
|
||||
@ -42,6 +45,7 @@ var App = settings{
|
||||
},
|
||||
}
|
||||
|
||||
// Setup initializes the App object parsing the flags
|
||||
func Setup(args []string) (output string, err error) {
|
||||
flags := flag.NewFlagSet("whatismyip", flag.ContinueOnError)
|
||||
var buf bytes.Buffer
|
||||
|
Reference in New Issue
Block a user