👔 Set default status code for redirect if not specified
/ docker (push) Successful in 1m19s
Details
/ docker (push) Successful in 1m19s
Details
This commit is contained in:
parent
f32551a748
commit
5adf0b6bef
|
@ -2,6 +2,7 @@ package usecase
|
|||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"source.toby3d.me/toby3d/home/internal/domain"
|
||||
"source.toby3d.me/toby3d/home/internal/server"
|
||||
|
@ -86,10 +87,9 @@ func parseRedirects(dst *domain.Server, params map[string]any) error {
|
|||
redirect := domain.Redirect{
|
||||
From: "",
|
||||
To: "",
|
||||
Status: 0,
|
||||
Status: http.StatusMovedPermanently,
|
||||
Force: false,
|
||||
}
|
||||
redirect.Force, _ = redirectMap["force"].(bool)
|
||||
|
||||
if redirect.From, ok = redirectMap["from"].(string); !ok {
|
||||
continue
|
||||
|
@ -99,10 +99,11 @@ func parseRedirects(dst *domain.Server, params map[string]any) error {
|
|||
continue
|
||||
}
|
||||
|
||||
if redirect.Status, ok = redirectMap["status"].(int); !ok {
|
||||
continue
|
||||
if status, ok := redirectMap["status"].(int); ok && status != 0 {
|
||||
redirect.Status = status
|
||||
}
|
||||
|
||||
redirect.Force, _ = redirectMap["force"].(bool)
|
||||
dst.Redirects = append(dst.Redirects, redirect)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue