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

View File

@@ -0,0 +1,34 @@
package handlers
import (
"io"
"github.com/guisea/directdnsonly/internal/util"
"github.com/labstack/echo/v4"
)
func DNSAdmin(c echo.Context) error {
// Implementation still to come
if c.Request().Method == "POST" {
action := c.QueryParam("action")
c.Logger().Debug("Action received via querystring: " + action)
body := c.Request().Body
respBytes, err := io.ReadAll(body)
if err != nil {
c.Logger().Error(err)
}
c.Logger().Debugf("Body of request: %s", respBytes)
if action == "" {
c.Logger().Debug("Action was not found, check body")
decoded_params := util.DecodeParams(string(respBytes))
c.Logger().Debugf("Parameters decoded: %s", decoded_params)
action = decoded_params["action"]
}
// zone_file := body
}
if c.Request().Method == "GET" {
// Implement some stuff
}
return nil
}

View File

@@ -0,0 +1,20 @@
package handlers
import (
"net/http"
"github.com/guisea/directdnsonly/internal/responses"
"github.com/guisea/directdnsonly/internal/util"
"github.com/labstack/echo/v4"
)
// Login - LoginTest endpoint allows DirectAdmin to check login details
// As we have set Basic Auth middleware just returns message
func LoginTest(c echo.Context) error {
// Construct a response
resp := responses.DAResponse{}
resp.Error = 0
resp.Message = "Login OK"
// Returns the response to the client
return c.String(http.StatusOK, util.EncodeQueryString(resp))
}