feat(option): seed and validate origin error page options

This commit is contained in:
ryan
2026-08-06 13:59:54 +08:00
parent 68d8f786cc
commit 7d47db1f34
10 changed files with 398 additions and 82 deletions
+8
View File
@@ -1,3 +1,6 @@
// Copyright 2026 Arctel.net
// SPDX-License-Identifier: Apache-2.0
package openresty
import (
@@ -8,10 +11,14 @@ import (
)
const (
// StatusCodeMin is the lowest HTTP status code accepted for origin error pages.
StatusCodeMin = 400
// StatusCodeMax is the highest HTTP status code accepted for origin error pages.
StatusCodeMax = 599
)
// ParseStatusCodeTag parses a single tag such as "502" or "500-599".
// Bounds must fall within StatusCodeMin–StatusCodeMax inclusive.
func ParseStatusCodeTag(tag string) (lo, hi int, err error) {
tag = strings.TrimSpace(tag)
if tag == "" {
@@ -42,6 +49,7 @@ func ParseStatusCodeTag(tag string) (lo, hi int, err error) {
return lo, hi, nil
}
// ExpandStatusCodeTags expands status code tags into a sorted unique list of integers.
func ExpandStatusCodeTags(tags []string) ([]int, error) {
set := map[int]struct{}{}
for _, tag := range tags {