Use gofmt -s
This commit is contained in:
parent
8d7c7a5a50
commit
0f2e7cf5e2
|
|
@ -1,14 +1,15 @@
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"errors"
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func withID(ctx *gin.Context, name string, f func(id uint)) {
|
func withID(ctx *gin.Context, name string, f func(id uint)) {
|
||||||
if id, err := strconv.ParseUint(ctx.Param(name), 10, 32); err == nil {
|
if id, err := strconv.ParseUint(ctx.Param(name), 10, 32); err == nil {
|
||||||
f(uint(id));
|
f(uint(id))
|
||||||
} else {
|
} else {
|
||||||
ctx.AbortWithError(400, errors.New("invalid id"))
|
ctx.AbortWithError(400, errors.New("invalid id"))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ func (a *MessageAPI) DeleteMessageWithApplication(ctx *gin.Context) {
|
||||||
} else {
|
} else {
|
||||||
ctx.AbortWithError(404, errors.New("application does not exists"))
|
ctx.AbortWithError(404, errors.New("application does not exists"))
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteMessage deletes a message with an id.
|
// DeleteMessage deletes a message with an id.
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,14 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/gotify/server/auth"
|
"github.com/gotify/server/auth"
|
||||||
"github.com/gotify/server/model"
|
|
||||||
"net/http"
|
|
||||||
"github.com/gotify/server/mode"
|
"github.com/gotify/server/mode"
|
||||||
"net/url"
|
"github.com/gotify/server/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
var upgrader = websocket.Upgrader{
|
var upgrader = websocket.Upgrader{
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/gotify/server/auth"
|
"github.com/gotify/server/auth"
|
||||||
|
"github.com/gotify/server/mode"
|
||||||
"github.com/gotify/server/model"
|
"github.com/gotify/server/model"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/gotify/server/mode"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFailureOnNormalHttpRequest(t *testing.T) {
|
func TestFailureOnNormalHttpRequest(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import (
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gotify/server/auth"
|
"github.com/gotify/server/auth"
|
||||||
"github.com/gotify/server/model"
|
|
||||||
"github.com/gotify/server/auth/password"
|
"github.com/gotify/server/auth/password"
|
||||||
|
"github.com/gotify/server/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The UserDatabase interface for encapsulating database access.
|
// The UserDatabase interface for encapsulating database access.
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/gotify/server/model"
|
|
||||||
"github.com/gotify/server/auth/password"
|
"github.com/gotify/server/auth/password"
|
||||||
|
"github.com/gotify/server/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/gotify/server/mode"
|
||||||
"github.com/gotify/server/model"
|
"github.com/gotify/server/model"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
"github.com/gotify/server/mode"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUtilSuite(t *testing.T) {
|
func TestUtilSuite(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/gotify/server/mode"
|
"github.com/gotify/server/mode"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestServe(t *testing.T) {
|
func TestServe(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/gotify/server/mode"
|
||||||
"github.com/gotify/server/model"
|
"github.com/gotify/server/model"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/gotify/server/mode"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDefaultErrorInternal(t *testing.T) {
|
func TestDefaultErrorInternal(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -11,22 +11,22 @@ const (
|
||||||
TestDev = "testdev"
|
TestDev = "testdev"
|
||||||
)
|
)
|
||||||
|
|
||||||
var mode = Dev;
|
var mode = Dev
|
||||||
|
|
||||||
// Set sets the new mode.
|
// Set sets the new mode.
|
||||||
func Set(newMode string) {
|
func Set(newMode string) {
|
||||||
mode = newMode;
|
mode = newMode
|
||||||
updateGinMode()
|
updateGinMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get returns the current mode.
|
// Get returns the current mode.
|
||||||
func Get() string {
|
func Get() string {
|
||||||
return mode;
|
return mode
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsDev returns true if the current mode is dev mode.
|
// IsDev returns true if the current mode is dev mode.
|
||||||
func IsDev() bool {
|
func IsDev() bool {
|
||||||
return Get() == Dev || Get() == TestDev;
|
return Get() == Dev || Get() == TestDev
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateGinMode() {
|
func updateGinMode() {
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@ package mode
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDevMode(t *testing.T) {
|
func TestDevMode(t *testing.T) {
|
||||||
|
|
@ -13,7 +14,6 @@ func TestDevMode(t *testing.T) {
|
||||||
assert.Equal(t, gin.Mode(), gin.DebugMode)
|
assert.Equal(t, gin.Mode(), gin.DebugMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func TestTestDevMode(t *testing.T) {
|
func TestTestDevMode(t *testing.T) {
|
||||||
Set(TestDev)
|
Set(TestDev)
|
||||||
assert.Equal(t, Get(), TestDev)
|
assert.Equal(t, Get(), TestDev)
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,3 @@ type VersionInfo struct {
|
||||||
// example: 2018-02-27T19:36:10.5045044+01:00
|
// example: 2018-02-27T19:36:10.5045044+01:00
|
||||||
BuildDate string `json:"buildDate"`
|
BuildDate string `json:"buildDate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ import (
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gotify/server/api/stream"
|
||||||
"github.com/gotify/server/config"
|
"github.com/gotify/server/config"
|
||||||
"github.com/gotify/server/docs"
|
"github.com/gotify/server/docs"
|
||||||
"github.com/gotify/server/model"
|
|
||||||
"github.com/gotify/server/api/stream"
|
|
||||||
"github.com/gotify/server/mode"
|
"github.com/gotify/server/mode"
|
||||||
|
"github.com/gotify/server/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create creates the gin engine with all routes.
|
// Create creates the gin engine with all routes.
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gobuffalo/packr"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/gobuffalo/packr"
|
||||||
)
|
)
|
||||||
|
|
||||||
var box = packr.NewBox("../ui/build")
|
var box = packr.NewBox("../ui/build")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue