Documentation ¶
Index ¶
- func ReadRequest(w http.ResponseWriter, r *http.Request, data any) error
- func WriteResponse(w http.ResponseWriter, statusCode int, payload any, headers ...http.Header) error
- type BaseHandler
- func (h *BaseHandler) DomainCreate(w http.ResponseWriter, r *http.Request)
- func (h *BaseHandler) DomainDelete(w http.ResponseWriter, r *http.Request)
- func (h *BaseHandler) DomainGet(w http.ResponseWriter, r *http.Request)
- func (h *BaseHandler) DomainUpdate(w http.ResponseWriter, r *http.Request)
- func (h *BaseHandler) Inspect(w http.ResponseWriter, r *http.Request)
- type CreateDomainRequest
- type ErrorResponse
- type InspectRequestPayload
- type RPCLookupPayload
- type Response
- type UpdateDomainRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadRequest ¶
ReadRequest tries to read the body of a request and converts it into JSON
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, statusCode int, payload any, headers ...http.Header) error
WriteResponse takes a response status code and arbitrary data and writes a json response to the client
Types ¶
type BaseHandler ¶
type BaseHandler struct {
// contains filtered or unexported fields
}
func NewBaseHandler ¶
func NewBaseHandler( log *logrus.Logger, domainRepo models.DomainRepository, rootDomainRepo models.RootDomainRepository, ) *BaseHandler
func (*BaseHandler) DomainCreate ¶
func (h *BaseHandler) DomainCreate(w http.ResponseWriter, r *http.Request)
DomainCreate godoc @Summary create domain @Tags domains @Accept json @Produce application/json @Param comment body CreateDomainRequest true "raw request body" @Security BearerAuth @Success 200 {object} Response{data=models.Domain} @Failure 400 {object} ErrorResponse @Failure 401 {object} ErrorResponse @Failure 403 {object} ErrorResponse @Failure 409 {object} ErrorResponse @Failure 422 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/domains [post]
func (*BaseHandler) DomainDelete ¶
func (h *BaseHandler) DomainDelete(w http.ResponseWriter, r *http.Request)
DomainDelete godoc @Summary delete domain by Domain Name @Tags domains @Accept json @Produce application/json @Param domainName path string true "Domain Name" @Security BearerAuth @Success 200 {object} Response @Failure 400 {object} ErrorResponse @Failure 401 {object} ErrorResponse @Failure 403 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/domains/{domainName} [delete]
func (*BaseHandler) DomainGet ¶
func (h *BaseHandler) DomainGet(w http.ResponseWriter, r *http.Request)
DomainGet godoc @Summary get domain by Domain Name @Tags domains @Accept json @Produce application/json @Param domainName path string true "Domain Name" @Security BearerAuth @Success 200 {object} Response{data=models.Domain} @Failure 400 {object} ErrorResponse @Failure 401 {object} ErrorResponse @Failure 403 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/domains/{domainName} [get]
func (*BaseHandler) DomainUpdate ¶
func (h *BaseHandler) DomainUpdate(w http.ResponseWriter, r *http.Request)
DomainUpdate godoc @Summary update domain by Domain Name @Tags domains @Accept json @Produce application/json @Param domainName path string true "Domain Name" @Param comment body models.Domain true "raw request body" @Security BearerAuth @Success 200 {object} Response{data=models.Domain} @Failure 400 {object} ErrorResponse @Failure 401 {object} ErrorResponse @Failure 403 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 422 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/domains/{domainName} [patch]
func (*BaseHandler) Inspect ¶
func (h *BaseHandler) Inspect(w http.ResponseWriter, r *http.Request)
Inspect godoc @Summary get information about domain name or email address @Tags inspect @Accept json @Produce application/json @Param data body InspectRequestPayload true "raw request body" @Security X-API-KEY @Success 200 {object} Response{data=string} @Failure 400 {object} ErrorResponse @Failure 401 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/inspect [post]
type CreateDomainRequest ¶
type ErrorResponse ¶
type ErrorResponse struct { Code int `json:"code"` Message string `json:"message"` Data any `json:"data,omitempty"` }
ErrorResponse is the type used for sending JSON around
func NewErrorPayload ¶
func NewErrorPayload(code int, message string, err error) *ErrorResponse