mirror of
https://github.com/MizuchiLabs/mantrae.git
synced 2026-05-08 00:49:49 -05:00
fixed some forms
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
type UpsertMiddlewareParams struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Protocol string `json:"protocol"`
|
||||
Middleware *runtime.MiddlewareInfo `json:"middleware"`
|
||||
TCPMiddleware *runtime.TCPMiddlewareInfo `json:"tcpMiddleware"`
|
||||
}
|
||||
@@ -79,6 +79,9 @@ func UpsertMiddleware(q *db.Queries) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// Initialize maps if nil
|
||||
if existingConfig.Config == nil {
|
||||
existingConfig.Config = &db.TraefikConfiguration{}
|
||||
}
|
||||
if existingConfig.Config.Middlewares == nil {
|
||||
existingConfig.Config.Middlewares = make(map[string]*runtime.MiddlewareInfo)
|
||||
}
|
||||
@@ -92,7 +95,7 @@ func UpsertMiddleware(q *db.Queries) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// Update configuration based on type
|
||||
switch params.Type {
|
||||
switch params.Protocol {
|
||||
case "http":
|
||||
existingConfig.Config.Middlewares[params.Name] = params.Middleware
|
||||
case "tcp":
|
||||
@@ -129,9 +132,9 @@ func DeleteMiddleware(q *db.Queries) http.HandlerFunc {
|
||||
}
|
||||
|
||||
mwName := r.PathValue("name")
|
||||
mwType := r.PathValue("type")
|
||||
mwProto := r.PathValue("protocol")
|
||||
|
||||
if mwName == "" || mwType == "" {
|
||||
if mwName == "" || mwProto == "" {
|
||||
http.Error(w, "Missing middleware name or type", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
@@ -158,7 +161,7 @@ func DeleteMiddleware(q *db.Queries) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// Remove router and service based on type
|
||||
switch mwType {
|
||||
switch mwProto {
|
||||
case "http":
|
||||
delete(existingConfig.Config.Middlewares, mwName)
|
||||
case "tcp":
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
type UpsertRouterParams struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Protocol string `json:"protocol"`
|
||||
Router *runtime.RouterInfo `json:"router"`
|
||||
TCPRouter *runtime.TCPRouterInfo `json:"tcpRouter"`
|
||||
UDPRouter *runtime.UDPRouterInfo `json:"udpRouter"`
|
||||
@@ -90,7 +90,7 @@ func UpsertRouter(q *db.Queries) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// Update configuration based on type
|
||||
switch params.Type {
|
||||
switch params.Protocol {
|
||||
case "http":
|
||||
existingConfig.Config.Routers[params.Name] = params.Router
|
||||
existingConfig.Config.Services[params.Name] = params.Service
|
||||
@@ -203,7 +203,7 @@ func validateRouterParams(params *UpsertRouterParams) error {
|
||||
return ErrInvalidName
|
||||
}
|
||||
|
||||
switch params.Type {
|
||||
switch params.Protocol {
|
||||
case "http":
|
||||
if params.Router == nil {
|
||||
return ErrMissingRouter
|
||||
|
||||
Reference in New Issue
Block a user