Skip to content

Commit f732d59

Browse files
committed
Bumped v0.4.0
Signed-off-by: Vishal Rana <[email protected]>
1 parent 6d51254 commit f732d59

File tree

4 files changed

+12
-47
lines changed

4 files changed

+12
-47
lines changed

Gopkg.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
[[constraint]]
3737
name = "github.com/labstack/labstack-go"
38-
version = "0.8.2"
38+
version = "0.8.7"
3939

4040
[[constraint]]
4141
name = "github.com/stretchr/testify"

cube/cube.go

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
package cube
22

33
import (
4-
"fmt"
5-
"net/http"
6-
"runtime"
7-
"time"
8-
94
"github.com/labstack/echo"
105
"github.com/labstack/echo/middleware"
116
"github.com/labstack/labstack-go"
@@ -14,35 +9,17 @@ import (
149
type (
1510
// Config defines the config for Cube middleware.
1611
Config struct {
12+
labstack.Cube
13+
1714
// Skipper defines a function to skip middleware.
1815
Skipper middleware.Skipper
19-
20-
// LabStack Account ID
21-
AccountID string `json:"account_id"`
22-
23-
// LabStack API key
24-
APIKey string `json:"api_key"`
25-
26-
// Number of requests in a batch
27-
BatchSize int `json:"batch_size"`
28-
29-
// Interval in seconds to dispatch the batch
30-
DispatchInterval time.Duration `json:"dispatch_interval"`
31-
32-
// Additional tags
33-
Tags []string `json:"tags"`
34-
35-
// TODO: To be implemented
36-
ClientLookup string `json:"client_lookup"`
3716
}
3817
)
3918

4019
var (
4120
// DefaultConfig is the default Cube middleware config.
4221
DefaultConfig = Config{
43-
Skipper: middleware.DefaultSkipper,
44-
BatchSize: 60,
45-
DispatchInterval: 60,
22+
Skipper: middleware.DefaultSkipper,
4623
}
4724
)
4825

@@ -86,28 +63,15 @@ func MiddlewareWithConfig(config Config) echo.MiddlewareFunc {
8663
}
8764

8865
// Start
89-
cr := cube.Start(c.Request(), c.Response())
66+
r := cube.Start(c.Request(), c.Response())
9067

9168
// Handle panic
9269
defer func() {
93-
if r := recover(); r != nil {
94-
switch r := r.(type) {
95-
case error:
96-
err = r
97-
default:
98-
err = fmt.Errorf("%v", r)
99-
}
100-
stack := make([]byte, 4<<10) // 4 KB
101-
length := runtime.Stack(stack, false)
102-
cr.Error = err.Error()
103-
cr.StackTrace = string(stack[:length])
104-
if c.Response().Status == http.StatusOK {
105-
c.Response().Status = http.StatusInternalServerError
106-
}
107-
}
70+
// Recover
71+
cube.Recover(recover(), r)
10872

10973
// Stop
110-
cube.Stop(cr, c.Response().Status, c.Response().Size)
74+
cube.Stop(r, c.Response().Status, c.Response().Size)
11175
}()
11276

11377
// Next

cube/cube_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package cube

0 commit comments

Comments
 (0)