MCPcopy
hub / github.com/caddyserver/caddy / TestRedirDirectiveSyntax

Function TestRedirDirectiveSyntax

caddyconfig/httpcaddyfile/builtins_test.go:98–233  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestRedirDirectiveSyntax(t *testing.T) {
99 for i, tc := range []struct {
100 input string
101 expectError bool
102 }{
103 {
104 input: `:8080 {
105 redir :8081
106 }`,
107 expectError: false,
108 },
109 {
110 input: `:8080 {
111 redir * :8081
112 }`,
113 expectError: false,
114 },
115 {
116 input: `:8080 {
117 redir /api/* :8081 300
118 }`,
119 expectError: false,
120 },
121 {
122 input: `:8080 {
123 redir :8081 300
124 }`,
125 expectError: false,
126 },
127 {
128 input: `:8080 {
129 redir /api/* :8081 399
130 }`,
131 expectError: false,
132 },
133 {
134 input: `:8080 {
135 redir :8081 399
136 }`,
137 expectError: false,
138 },
139 {
140 input: `:8080 {
141 redir /old.html /new.html
142 }`,
143 expectError: false,
144 },
145 {
146 input: `:8080 {
147 redir /old.html /new.html temporary
148 }`,
149 expectError: false,
150 },
151 {
152 input: `:8080 {
153 redir https://example.com{uri} permanent
154 }`,
155 expectError: false,

Callers

nothing calls this directly

Calls 1

AdaptMethod · 0.95

Tested by

no test coverage detected