go fmt
This commit is contained in:
parent
984be2f57e
commit
b91d8b5fda
28
main.go
28
main.go
|
@ -1,15 +1,15 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
proxyproto "github.com/pires/go-proxyproto"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"encoding/json"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
proxyproto "github.com/pires/go-proxyproto"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
|
@ -157,13 +157,13 @@ func mainHandler(c *gin.Context) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
case "headers":
|
case "headers":
|
||||||
if wantsJS {
|
if wantsJS {
|
||||||
c.Writer.Header().Set("Content-Type", "application/javascript")
|
c.Writer.Header().Set("Content-Type", "application/javascript")
|
||||||
response, _ := json.Marshal(c.Request.Header)
|
response, _ := json.Marshal(c.Request.Header)
|
||||||
c.String(200, "ifconfig_io = %v\n", string(response))
|
c.String(200, "ifconfig_io = %v\n", string(response))
|
||||||
} else {
|
} else {
|
||||||
c.JSON(200, c.Request.Header)
|
c.JSON(200, c.Request.Header)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fieldResult, exists := c.Get(fields[0])
|
fieldResult, exists := c.Get(fields[0])
|
||||||
|
@ -174,10 +174,10 @@ func mainHandler(c *gin.Context) {
|
||||||
if wantsJSON {
|
if wantsJSON {
|
||||||
c.JSON(200, fieldResult)
|
c.JSON(200, fieldResult)
|
||||||
} else if wantsJS {
|
} else if wantsJS {
|
||||||
c.Writer.Header().Set("Content-Type", "application/javascript")
|
c.Writer.Header().Set("Content-Type", "application/javascript")
|
||||||
response, _ := json.Marshal(map[string]interface{}{fields[0]: fieldResult})
|
response, _ := json.Marshal(map[string]interface{}{fields[0]: fieldResult})
|
||||||
c.String(200, "ifconfig_io = %v\n", string(response))
|
c.String(200, "ifconfig_io = %v\n", string(response))
|
||||||
} else {
|
} else {
|
||||||
c.String(200, fmt.Sprintln(fieldResult))
|
c.String(200, fmt.Sprintln(fieldResult))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue