WIP endpoint for listing available modifiers for frontend

This commit is contained in:
Kevin Pham
2023-12-07 11:41:54 -06:00
parent 0b084f44ae
commit c9bb0f6c25
2 changed files with 65 additions and 2 deletions

View File

@@ -1 +1,64 @@
package handlers
// TODO: this is a work in progress.
// Needs codegen to populate the rqm and rsm structs from available modifiers in ladder/proxychain/*modifers/*.go
import (
"ladder/proxychain/responsemodifiers/api"
)
type ModifiersAPIResponse struct {
Success bool `json:"success"`
Error api.Error `json:"error"`
Result Modifiers `json:"result"`
}
type Modifiers struct {
RequestModifiers []Modifier `json:"requestmodifiers"`
ResponseModifiers []Modifier `json:"responsemodifiers"`
}
type Modifier struct {
Name string `json:"name"`
Description string `json:"description"`
Params []Param `json:"params"`
}
type Param struct {
Name string `json:"name"`
Type string `json:"type"`
}
func init() {
rqm := []Modifier{}
// ========= loop
rqm = append(rqm, Modifier{
Name: "codegen_name",
Description: "codegen_description",
Params: []Param{
{Name: "codegen_name1", Type: "codegen_type1"},
{Name: "codegen_name2", Type: "codegen_type2"},
},
})
// ========= loop end
rsm := []Modifier{}
// ========= loop
rsm = append(rsm, Modifier{
Name: "codegen_name",
Description: "codegen_description",
Params: []Param{
{Name: "codegen_name1", Type: "codegen_type1"},
{Name: "codegen_name2", Type: "codegen_type2"},
},
})
// ========= loop end
m := &ModifiersAPIResponse{Success: true}
m.Result.RequestModifiers = rqm
m.Result.ResponseModifiers = rsm
}

View File

@@ -1,7 +1,7 @@
package requestmodifiers
import (
"fmt"
//"fmt"
"net/url"
"ladder/proxychain"
@@ -13,7 +13,7 @@ func ModifyQueryParams(key string, value string) proxychain.RequestModification
return func(chain *proxychain.ProxyChain) error {
q := chain.Request.URL.Query()
chain.Request.URL.RawQuery = modifyQueryParams(key, value, q)
fmt.Println(chain.Request.URL.String())
//fmt.Println(chain.Request.URL.String())
return nil
}
}