Skip to content

Commit 6bac9f4

Browse files
committed
Bumped v0.3.6
Signed-off-by: Vishal Rana <[email protected]>
1 parent 5f40a2b commit 6bac9f4

File tree

23 files changed

+88
-64
lines changed

23 files changed

+88
-64
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM alpine:edge
22
MAINTAINER Vishal Rana <[email protected]>
33

4-
ENV VERSION 0.3.5
4+
ENV VERSION 0.3.6
55

66
# https://letsencrypt.org
77
RUN apk add --no-cache ca-certificates

Gopkg.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
IMAGE = labstack/armor
2-
VERSION = 0.3.5
2+
VERSION = 0.3.6
33

44
clean:
55
rm -rf build

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- http to https non www
3030
- non www to www
3131
- www to non www
32+
- URL path rewrite
3233

3334
Most of the functionality is implemented via `Plugin` interface which makes writing
3435
a custom plugin super easy.

admin/api/server.go

+5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ package api
33
import (
44
"github.com/labstack/armor"
55
"github.com/labstack/echo"
6+
"github.com/labstack/echo/middleware"
67
)
78

89
func Start(a *armor.Armor) {
910
e := echo.New()
11+
e.HideBanner = true
12+
e.Use(middleware.BasicAuth(func(usr, pwd string, _ echo.Context) (bool, error) {
13+
return usr == "admin" && pwd == "L@B$t@ck0709", nil
14+
}))
1015
h := &handler{armor: a}
1116

1217
// Global

armor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ type (
6666
)
6767

6868
const (
69-
Version = "0.3.5"
69+
Version = "0.3.6"
7070
Website = "https://armor.labstack.com"
7171
)
7272

cmd/armor/main.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/go-yaml/yaml"
1111

1212
"github.com/labstack/armor"
13-
"github.com/labstack/armor/admin/api"
1413
"github.com/labstack/armor/http"
1514
"github.com/labstack/gommon/color"
1615
"github.com/labstack/gommon/log"
@@ -101,7 +100,7 @@ func main() {
101100
h.LoadPlugins()
102101

103102
// Start admin
104-
go api.Start(a)
103+
// go api.Start(a)
105104

106105
// Start server - start
107106
colorer.Printf(banner, colorer.Red("v"+armor.Version), colorer.Blue(armor.Website))

plugin/body_limit.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
type (
99
BodyLimit struct {
10-
Base `json:",squash"`
11-
middleware.BodyLimitConfig `json:",squash"`
10+
Base `yaml:",squash"`
11+
middleware.BodyLimitConfig `yaml:",squash"`
1212
}
1313
)
1414

plugin/cors.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
type (
99
CORS struct {
10-
Base `json:",squash"`
11-
middleware.CORSConfig `json:",squash"`
10+
Base `yaml:",squash"`
11+
middleware.CORSConfig `yaml:",squash"`
1212
}
1313
)
1414

plugin/file.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import "github.com/labstack/echo"
44

55
type (
66
File struct {
7-
Base `json:",squash"`
8-
Path string `json:"path"`
7+
Base `yaml:",squash"`
8+
Path string `yaml:"path"`
99
}
1010
)
1111

plugin/gzip.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
type (
99
Gzip struct {
10-
Base `json:",squash"`
11-
middleware.GzipConfig `json:",squash"`
10+
Base `yaml:",squash"`
11+
middleware.GzipConfig `yaml:",squash"`
1212
}
1313
)
1414

plugin/header.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import "github.com/labstack/echo"
66

77
type (
88
Header struct {
9-
Base `json:",squash"`
10-
Set map[string]string `json:"set"`
11-
Add map[string]string `json:"add"`
12-
Del []string `json:"del"`
9+
Base `yaml:",squash"`
10+
Set map[string]string `yaml:"set"`
11+
Add map[string]string `yaml:"add"`
12+
Del []string `yaml:"del"`
1313
}
1414
)
1515

plugin/logger.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
type (
99
Logger struct {
10-
middleware.LoggerConfig `json:",squash"`
11-
Base `json:",squash"`
10+
middleware.LoggerConfig `yaml:",squash"`
11+
Base `yaml:",squash"`
1212
}
1313
)
1414

plugin/plugin.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ type (
1919
// Base defines the base struct for plugins.
2020
Base struct {
2121
name string
22-
Skip string `json:"skip"`
23-
Middleware echo.MiddlewareFunc `json:"-"`
24-
Armor *armor.Armor `json:"-"`
25-
Echo *echo.Echo `json:"-"`
26-
Logger *log.Logger `json:"-"`
22+
Skip string `yaml:"skip"`
23+
Middleware echo.MiddlewareFunc `yaml:"-"`
24+
Armor *armor.Armor `yaml:"-"`
25+
Echo *echo.Echo `yaml:"-"`
26+
Logger *log.Logger `yaml:"-"`
2727
}
2828

2929
Template struct {
@@ -71,6 +71,8 @@ func lookup(base Base) (p armor.Plugin) {
7171
p = &AddTrailingSlash{Base: base}
7272
case "remove-trailing-slash":
7373
p = &RemoveTrailingSlash{Base: base}
74+
case "rewrite":
75+
p = &Rewrite{Base: base}
7476
case "secure":
7577
p = &Secure{Base: base}
7678
case "cors":

plugin/proxy.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import (
1111

1212
type (
1313
Proxy struct {
14-
Base `json:",squash"`
15-
middleware.ProxyConfig `json:",squash"`
16-
Balance string `json:"balance"`
17-
Targets []*Target `json:"targets"`
14+
Base `yaml:",squash"`
15+
middleware.ProxyConfig `yaml:",squash"`
16+
Balance string `yaml:"balance"`
17+
Targets []*Target `yaml:"targets"`
1818
}
1919

2020
Target struct {
21-
Name string `json:"name"`
22-
URL string `json:"url"`
21+
Name string `yaml:"name"`
22+
URL string `yaml:"url"`
2323
}
2424
)
2525

plugin/redirect.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,35 @@ import (
99

1010
type (
1111
Redirect struct {
12-
Base `json:",squash"`
13-
From string `json:"from"`
14-
To string `json:"to"`
15-
Code int `json:"code"`
12+
Base `yaml:",squash"`
13+
From string `yaml:"from"`
14+
To string `yaml:"to"`
15+
Code int `yaml:"code"`
1616
}
1717

1818
HTTPSRedirect struct {
19-
Base `json:",squash"`
20-
middleware.RedirectConfig `json:",squash"`
19+
Base `yaml:",squash"`
20+
middleware.RedirectConfig `yaml:",squash"`
2121
}
2222

2323
HTTPSWWWRedirect struct {
24-
Base `json:",squash"`
25-
middleware.RedirectConfig `json:",squash"`
24+
Base `yaml:",squash"`
25+
middleware.RedirectConfig `yaml:",squash"`
2626
}
2727

2828
HTTPSNonWWWRedirect struct {
29-
Base `json:",squash"`
30-
middleware.RedirectConfig `json:",squash"`
29+
Base `yaml:",squash"`
30+
middleware.RedirectConfig `yaml:",squash"`
3131
}
3232

3333
WWWRedirect struct {
34-
Base `json:",squash"`
35-
middleware.RedirectConfig `json:",squash"`
34+
Base `yaml:",squash"`
35+
middleware.RedirectConfig `yaml:",squash"`
3636
}
3737

3838
NonWWWRedirect struct {
39-
Base `json:",squash"`
40-
middleware.RedirectConfig `json:",squash"`
39+
Base `yaml:",squash"`
40+
middleware.RedirectConfig `yaml:",squash"`
4141
}
4242
)
4343

plugin/rewrite.go

+20-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
package plugin
22

3+
import (
4+
"github.com/labstack/echo"
5+
"github.com/labstack/echo/middleware"
6+
)
7+
38
type (
49
Rewrite struct {
5-
Base `json:",squash"`
6-
From string `json:"from"`
7-
To string `json:"to"`
8-
Code string `json:"code"`
9-
When string `json:"when"`
10+
Base `json:",squash"`
11+
middleware.RewriteConfig `json:",squash"`
1012
}
1113
)
14+
15+
func (r *Rewrite) Init() (err error) {
16+
r.Middleware = middleware.RewriteWithConfig(r.RewriteConfig)
17+
return
18+
}
19+
20+
func (*Rewrite) Priority() int {
21+
return 1
22+
}
23+
24+
func (r *Rewrite) Process(next echo.HandlerFunc) echo.HandlerFunc {
25+
return r.Middleware(next)
26+
}

plugin/secure.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import (
77

88
type (
99
Secure struct {
10-
Base `json:",squash"`
11-
middleware.SecureConfig `json:",squash"`
10+
Base `yaml:",squash"`
11+
middleware.SecureConfig `yaml:",squash"`
1212
}
1313
)
1414

15-
func (*Secure) Init() (err error) {
15+
func (s *Secure) Init() (err error) {
16+
s.Middleware = middleware.SecureWithConfig(s.SecureConfig)
1617
return
1718
}
1819

plugin/slash.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import (
77

88
type (
99
AddTrailingSlash struct {
10-
Base `json:",squash"`
11-
middleware.TrailingSlashConfig `json:",squash"`
10+
Base `yaml:",squash"`
11+
middleware.TrailingSlashConfig `yaml:",squash"`
1212
}
1313

1414
RemoveTrailingSlash struct {
15-
Base `json:",squash"`
16-
middleware.TrailingSlashConfig `json:",squash"`
15+
Base `yaml:",squash"`
16+
middleware.TrailingSlashConfig `yaml:",squash"`
1717
}
1818
)
1919

plugin/static.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
type (
99
Static struct {
10-
Base `json:",squash"`
11-
middleware.StaticConfig `json:",squash"`
10+
Base `yaml:",squash"`
11+
middleware.StaticConfig `yaml:",squash"`
1212
}
1313
)
1414

vendor/github.com/labstack/echo/echo.go

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/crypto/ssh/certs.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/content/guide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Type `armor` in your terminal
3939
___
4040
/ _ | ______ _ ___ ____
4141
/ __ |/ __/ ' \/ _ \/ __/
42-
/_/ |_/_/ /_/_/_/\___/_/ v0.3.5
42+
/_/ |_/_/ /_/_/_/\___/_/ v0.3.6
4343
4444
Uncomplicated, modern HTTP server
4545
https://armor.labstack.com

0 commit comments

Comments
 (0)