dto

package
v0.0.0-...-d46a54d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToProxyServer

func ToProxyServer(s ServerDTO) (domain.ProxyServer, error)

ToProxyServer converts DTO object to proxyServer domain object

func ToRule

func ToRule(r RuleDTO) (domain.Rule, error)

ToRule converts DTO object to rule domain object

Types

type APIResponse

type APIResponse struct {
	Data    interface{} `json:"data"`
	Success bool        `json:"success"`
}

APIResponse is common response structure for all responses

type ReplacementDTO

type ReplacementDTO struct {
	Regex string `json:"regex"`
	Value string `json:"value"`
}

ReplacementDTO is DTO for replacements

type RequestDTO

type RequestDTO struct {
	ID           string    `json:"id"`
	Service      string    `json:"service"`
	RequestTime  time.Time `json:"request_time"`
	RequestSize  int64     `json:"request_size"`
	ResponseTime time.Time `json:"response_time"`
	ResponseSize int64     `json:"response_size"`
	Request      string    `json:"request_body,omitempty"`
	Response     string    `json:"response_body,omitempty"`
}

RequestDTO is DTO for request

func RequestToDTO

func RequestToDTO(req domain.Request) RequestDTO

RequestToDTO converts domain object to DTO without request/response body elements

func RequestToFullDTO

func RequestToFullDTO(req domain.Request) RequestDTO

RequestToFullDTO converts domain object to DTO with all fields included

func RequestsToDTO

func RequestsToDTO(reqs []domain.Request) []RequestDTO

RequestsToDTO converts slice of request to DTOs

type RuleDTO

type RuleDTO struct {
	ID                   int64            `json:"id"`
	Server               string           `json:"server"`
	Service              string           `json:"service"`
	Priority             int64            `json:"priority"`
	MatcherRemoteAddr    []string         `json:"matcher_remote_addr"`
	MatcherRegex         []string         `json:"matcher_regexes"`
	RequestReplacements  []ReplacementDTO `json:"request_replacements"`
	ResponseReplacements []ReplacementDTO `json:"response_replacements"`
	IsReadOnly           bool             `json:"read_only"`
}

RuleDTO is DTO for rule

func RuleToDTO

func RuleToDTO(r domain.Rule) RuleDTO

RuleToDTO converts rule to DTO

func RulesToDTO

func RulesToDTO(rules []domain.Rule) []RuleDTO

RulesToDTO converts slice of rules to DTOs

type ServerDTO

type ServerDTO struct {
	ID         int64   `json:"id"`
	Name       string  `json:"name"`
	Address    string  `json:"address"`
	IsReadOnly bool    `json:"read_only"`
	TLS        *TLSDTO `json:"tls,omitempty"`
}

ServerDTO is DTO for proxyServer

func ProxyServerToDTO

func ProxyServerToDTO(s domain.ProxyServer) ServerDTO

ProxyServerToDTO converts proxy server to DTO

func ProxyServersToDTO

func ProxyServersToDTO(rules []domain.ProxyServer) []ServerDTO

ProxyServersToDTO converts slice of servers to DTOs

type TLSDTO

type TLSDTO struct {
	UseSystemTransport bool   `json:"use_system_transport"`
	CACert             string `json:"ca_cert"`
	Cert               string `json:"cert"`
	Key                string `json:"key"`
	KeyPassword        string `json:"key_password"`
}

TLSDTO is DTO for server TLS configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL