mirror of https://github.com/gin-gonic/gin.git
Some cosmetic changes
This commit is contained in:
parent
c8ee142717
commit
615c62d736
15
gin.go
15
gin.go
|
@ -5,12 +5,13 @@
|
|||
package gin
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin/render"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"html/template"
|
||||
"math"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/gin-gonic/gin/render"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -158,16 +159,10 @@ func (engine *Engine) ServeHTTP(writer http.ResponseWriter, request *http.Reques
|
|||
|
||||
func (engine *Engine) Run(addr string) error {
|
||||
debugPrint("Listening and serving HTTP on %s\n", addr)
|
||||
if err := http.ListenAndServe(addr, engine); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return http.ListenAndServe(addr, engine)
|
||||
}
|
||||
|
||||
func (engine *Engine) RunTLS(addr string, cert string, key string) error {
|
||||
debugPrint("Listening and serving HTTPS on %s\n", addr)
|
||||
if err := http.ListenAndServeTLS(addr, cert, key, engine); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return http.ListenAndServeTLS(addr, cert, key, engine)
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ func TestHandleHeadToDir(t *testing.T) {
|
|||
// TEST
|
||||
bodyAsString := w.Body.String()
|
||||
if w.Code != 200 {
|
||||
t.Errorf("Response code should be Ok, was: %s", w.Code)
|
||||
t.Errorf("Response code should be Ok, was: %d", w.Code)
|
||||
}
|
||||
if len(bodyAsString) == 0 {
|
||||
t.Errorf("Got empty body instead of file tree")
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestPanicInHandler(t *testing.T) {
|
|||
log.SetOutput(os.Stderr)
|
||||
|
||||
if w.Code != 500 {
|
||||
t.Errorf("Response code should be Internal Server Error, was: %s", w.Code)
|
||||
t.Errorf("Response code should be Internal Server Error, was: %d", w.Code)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,6 @@ func TestPanicWithAbort(t *testing.T) {
|
|||
|
||||
// TEST
|
||||
if w.Code != 500 {
|
||||
t.Errorf("Response code should be Bad request, was: %s", w.Code)
|
||||
t.Errorf("Response code should be Bad request, was: %d", w.Code)
|
||||
}
|
||||
}
|
||||
|
|
9
utils.go
9
utils.go
|
@ -56,17 +56,16 @@ func chooseData(custom, wildcard interface{}) interface{} {
|
|||
return custom
|
||||
}
|
||||
|
||||
func parseAccept(accept string) []string {
|
||||
parts := strings.Split(accept, ",")
|
||||
func parseAccept(acceptHeader string) (parts []string) {
|
||||
parts = strings.Split(acceptHeader, ",")
|
||||
for i, part := range parts {
|
||||
index := strings.IndexByte(part, ';')
|
||||
if index >= 0 {
|
||||
part = part[0:index]
|
||||
}
|
||||
part = strings.TrimSpace(part)
|
||||
parts[i] = part
|
||||
parts[i] = strings.TrimSpace(part)
|
||||
}
|
||||
return parts
|
||||
return
|
||||
}
|
||||
|
||||
func lastChar(str string) uint8 {
|
||||
|
|
Loading…
Reference in New Issue