mirror of
https://github.com/gotify/server.git
synced 2024-01-28 15:20:56 +03:00
Use gofmt -s
This commit is contained in:
committed by
Jannis Mattheis
parent
8d7c7a5a50
commit
0f2e7cf5e2
@@ -1,14 +1,15 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func withID(ctx *gin.Context, name string, f func(id uint)) {
|
||||
if id, err := strconv.ParseUint(ctx.Param(name), 10, 32); err == nil {
|
||||
f(uint(id));
|
||||
f(uint(id))
|
||||
} else {
|
||||
ctx.AbortWithError(400, errors.New("invalid id"))
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func (a *MessageAPI) DeleteMessageWithApplication(ctx *gin.Context) {
|
||||
} else {
|
||||
ctx.AbortWithError(404, errors.New("application does not exists"))
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
// DeleteMessage deletes a message with an id.
|
||||
|
||||
@@ -4,13 +4,14 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/gotify/server/auth"
|
||||
"github.com/gotify/server/model"
|
||||
"net/http"
|
||||
"github.com/gotify/server/mode"
|
||||
"net/url"
|
||||
"github.com/gotify/server/model"
|
||||
)
|
||||
|
||||
var upgrader = websocket.Upgrader{
|
||||
|
||||
@@ -19,9 +19,9 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/gotify/server/auth"
|
||||
"github.com/gotify/server/mode"
|
||||
"github.com/gotify/server/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotify/server/mode"
|
||||
)
|
||||
|
||||
func TestFailureOnNormalHttpRequest(t *testing.T) {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gotify/server/auth"
|
||||
"github.com/gotify/server/model"
|
||||
"github.com/gotify/server/auth/password"
|
||||
"github.com/gotify/server/model"
|
||||
)
|
||||
|
||||
// The UserDatabase interface for encapsulating database access.
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gotify/server/model"
|
||||
"github.com/gotify/server/auth/password"
|
||||
"github.com/gotify/server/model"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -5,10 +5,10 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gotify/server/mode"
|
||||
"github.com/gotify/server/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/gotify/server/mode"
|
||||
)
|
||||
|
||||
func TestUtilSuite(t *testing.T) {
|
||||
|
||||
@@ -6,13 +6,13 @@ import "github.com/jinzhu/configor"
|
||||
type Configuration struct {
|
||||
Server struct {
|
||||
Port int `default:"80"`
|
||||
SSL struct {
|
||||
SSL struct {
|
||||
Enabled *bool `default:"false"`
|
||||
RedirectToHTTPS *bool `default:"true"`
|
||||
Port int `default:"443"`
|
||||
CertFile string `default:""`
|
||||
CertKey string `default:""`
|
||||
LetsEncrypt struct {
|
||||
LetsEncrypt struct {
|
||||
Enabled *bool `default:"false"`
|
||||
AcceptTOS *bool `default:"false"`
|
||||
Cache string `default:"certs"`
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotify/server/mode"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestServe(t *testing.T) {
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gotify/server/mode"
|
||||
"github.com/gotify/server/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/gotify/server/mode"
|
||||
)
|
||||
|
||||
func TestDefaultErrorInternal(t *testing.T) {
|
||||
|
||||
10
mode/mode.go
10
mode/mode.go
@@ -11,22 +11,22 @@ const (
|
||||
TestDev = "testdev"
|
||||
)
|
||||
|
||||
var mode = Dev;
|
||||
var mode = Dev
|
||||
|
||||
// Set sets the new mode.
|
||||
func Set(newMode string) {
|
||||
mode = newMode;
|
||||
mode = newMode
|
||||
updateGinMode()
|
||||
}
|
||||
|
||||
// Get returns the current mode.
|
||||
func Get() string {
|
||||
return mode;
|
||||
return mode
|
||||
}
|
||||
|
||||
// IsDev returns true if the current mode is dev mode.
|
||||
func IsDev() bool {
|
||||
return Get() == Dev || Get() == TestDev;
|
||||
return Get() == Dev || Get() == TestDev
|
||||
}
|
||||
|
||||
func updateGinMode() {
|
||||
@@ -40,4 +40,4 @@ func updateGinMode() {
|
||||
default:
|
||||
panic("unknown mode")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@ package mode
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDevMode(t *testing.T) {
|
||||
@@ -13,7 +14,6 @@ func TestDevMode(t *testing.T) {
|
||||
assert.Equal(t, gin.Mode(), gin.DebugMode)
|
||||
}
|
||||
|
||||
|
||||
func TestTestDevMode(t *testing.T) {
|
||||
Set(TestDev)
|
||||
assert.Equal(t, Get(), TestDev)
|
||||
@@ -32,4 +32,4 @@ func TestInvalidMode(t *testing.T) {
|
||||
assert.Panics(t, func() {
|
||||
Set("asdasda")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ type Error struct {
|
||||
//
|
||||
// required: true
|
||||
// example: Unauthorized
|
||||
Error string `json:"error"`
|
||||
Error string `json:"error"`
|
||||
// The http error code.
|
||||
//
|
||||
// required: true
|
||||
// example: 401
|
||||
ErrorCode int `json:"errorCode"`
|
||||
ErrorCode int `json:"errorCode"`
|
||||
// The http error code.
|
||||
//
|
||||
// required: true
|
||||
|
||||
@@ -20,4 +20,3 @@ type VersionInfo struct {
|
||||
// example: 2018-02-27T19:36:10.5045044+01:00
|
||||
BuildDate string `json:"buildDate"`
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@ import (
|
||||
|
||||
"net/http"
|
||||
|
||||
"github.com/gotify/server/api/stream"
|
||||
"github.com/gotify/server/config"
|
||||
"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/model"
|
||||
)
|
||||
|
||||
// Create creates the gin engine with all routes.
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"github.com/gobuffalo/packr"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gobuffalo/packr"
|
||||
)
|
||||
|
||||
var box = packr.NewBox("../ui/build")
|
||||
|
||||
Reference in New Issue
Block a user