You've already forked directdnsonly-go
Initial Project
This commit is contained in:
36
internal/util/util.go
Normal file
36
internal/util/util.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"github.com/google/go-querystring/query"
|
||||
"github.com/guisea/directdnsonly/internal/responses"
|
||||
)
|
||||
|
||||
func DecodeParams(payload string) map[string]string {
|
||||
// Parse the query string from the payload
|
||||
values, err := url.ParseQuery(payload)
|
||||
if err != nil {
|
||||
// Handle error, e.g., log it or return an error value
|
||||
return nil
|
||||
}
|
||||
|
||||
// Initialize a map to store the decoded parameters
|
||||
params := make(map[string]string)
|
||||
|
||||
// Iterate through the parameters
|
||||
for key, val := range values {
|
||||
// Store the first value of each parameter in the map
|
||||
if len(val) > 0 {
|
||||
params[key] = val[0]
|
||||
}
|
||||
}
|
||||
|
||||
// Return the decoded parameters as a map
|
||||
return params
|
||||
}
|
||||
|
||||
func EncodeQueryString(payload responses.DAResponse) string {
|
||||
QueryStringResponse, _ := query.Values(payload)
|
||||
return QueryStringResponse.Encode()
|
||||
}
|
||||
Reference in New Issue
Block a user