Linting middlewares package
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
7766d0ddaa
commit
9387235a04
4 changed files with 11 additions and 15 deletions
|
@ -1,6 +1,3 @@
|
||||||
/*
|
|
||||||
Copyright
|
|
||||||
*/
|
|
||||||
package middlewares
|
package middlewares
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -9,10 +6,12 @@ import (
|
||||||
"github.com/mailgun/oxy/cbreaker"
|
"github.com/mailgun/oxy/cbreaker"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CircuitBreaker holds the oxy circuit breaker.
|
||||||
type CircuitBreaker struct {
|
type CircuitBreaker struct {
|
||||||
circuitBreaker *cbreaker.CircuitBreaker
|
circuitBreaker *cbreaker.CircuitBreaker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewCircuitBreaker returns a new CircuitBreaker.
|
||||||
func NewCircuitBreaker(next http.Handler, expression string, options ...cbreaker.CircuitBreakerOption) *CircuitBreaker {
|
func NewCircuitBreaker(next http.Handler, expression string, options ...cbreaker.CircuitBreakerOption) *CircuitBreaker {
|
||||||
circuitBreaker, _ := cbreaker.New(next, expression, options...)
|
circuitBreaker, _ := cbreaker.New(next, expression, options...)
|
||||||
return &CircuitBreaker{circuitBreaker}
|
return &CircuitBreaker{circuitBreaker}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
/*
|
|
||||||
Copyright
|
|
||||||
*/
|
|
||||||
package middlewares
|
package middlewares
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -16,7 +13,7 @@ type Logger struct {
|
||||||
file *os.File
|
file *os.File
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLogger returns a new Logger instance
|
// NewLogger returns a new Logger instance.
|
||||||
func NewLogger(file string) *Logger {
|
func NewLogger(file string) *Logger {
|
||||||
if len(file) > 0 {
|
if len(file) > 0 {
|
||||||
fi, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
fi, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
||||||
|
@ -36,6 +33,7 @@ func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.Ha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close closes the logger (i.e. the file).
|
||||||
func (l *Logger) Close() {
|
func (l *Logger) Close() {
|
||||||
l.file.Close()
|
l.file.Close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
/*
|
|
||||||
Copyright
|
|
||||||
*/
|
|
||||||
package middlewares
|
package middlewares
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -11,10 +8,12 @@ import (
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Routes holds the gorilla mux routes (for the API & co).
|
||||||
type Routes struct {
|
type Routes struct {
|
||||||
router *mux.Router
|
router *mux.Router
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewRoutes return a Routes based on the given router.
|
||||||
func NewRoutes(router *mux.Router) *Routes {
|
func NewRoutes(router *mux.Router) *Routes {
|
||||||
return &Routes{router}
|
return &Routes{router}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
/*
|
|
||||||
Copyright
|
|
||||||
*/
|
|
||||||
package middlewares
|
package middlewares
|
||||||
|
|
||||||
import (
|
import (
|
||||||
log "github.com/Sirupsen/logrus"
|
|
||||||
"github.com/mailgun/oxy/roundrobin"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
log "github.com/Sirupsen/logrus"
|
||||||
|
"github.com/mailgun/oxy/roundrobin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// WebsocketUpgrader holds Websocket configuration.
|
||||||
type WebsocketUpgrader struct {
|
type WebsocketUpgrader struct {
|
||||||
rr *roundrobin.RoundRobin
|
rr *roundrobin.RoundRobin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewWebsocketUpgrader returns a new WebsocketUpgrader.
|
||||||
func NewWebsocketUpgrader(rr *roundrobin.RoundRobin) *WebsocketUpgrader {
|
func NewWebsocketUpgrader(rr *roundrobin.RoundRobin) *WebsocketUpgrader {
|
||||||
wu := WebsocketUpgrader{
|
wu := WebsocketUpgrader{
|
||||||
rr: rr,
|
rr: rr,
|
||||||
|
|
Loading…
Add table
Reference in a new issue