Initial Project

This commit is contained in:
2024-01-17 15:56:44 +13:00
parent 196e17cd29
commit 1e5f136257
14 changed files with 307 additions and 244 deletions

36
internal/util/util.go Normal file
View 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()
}