server

package
v1.9.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	/*DefaultClient : cliente http con parametros default*/
	DefaultClient = &Client{HTTPClient: &http.Client{}}
)

Functions

func AddQueryParameters

func AddQueryParameters(baseURL string, queryParams map[string]string) string

AddQueryParameters : agrega los parametros para un param querie

func AsigServer

func AsigServer(e *echo.Echo, cs []Controller) error

AsigServer : asigna peticiones a una instancia ECHO

func BasicAuth added in v1.7.8

func BasicAuth(username, password string) string

BasicAuth : autentificacion basica de un client http

func BuildRequestObject

func BuildRequestObject(request Request) (*http.Request, error)

BuildRequestObject : Contruccion de objeto http

func ExtKey

func ExtKey(c echo.Context) string

ExtKey : extrae el key de la sesion en el api

func JSONSend

func JSONSend(data StDataEnv, e echo.Context) error

JSONSend : envia un json generic

func MakeRequest

func MakeRequest(req *http.Request) (*http.Response, error)

MakeRequest : obtiene la respuesta de una peticion

func NewNetClient added in v1.7.8

func NewNetClient(timeout int) *http.Client

NewNetClient : crea una instancia de http client

func TokenHeaders added in v1.8.5

func TokenHeaders(token string) map[string]string

TokenHeaders : autentificacion por medio de token bearer

Types

type Browser

type Browser struct {
	Engine        string
	EngineVersion string
	Name          string
	Version       string
}

Browser : detecta el navegador que esta ocupando

type Client

type Client struct {
	HTTPClient *http.Client
}

Client : cliente http

func NewClient added in v1.7.8

func NewClient(timeout int) *Client

NewClient : crea una instancia client http

func (*Client) MakeRequest

func (c *Client) MakeRequest(req *http.Request) (*http.Response, error)

MakeRequest : envia la peticion de un servicio con un cliente por defecto

func (*Client) Send

func (c *Client) Send(request Request) (*Response, error)

Send : envia una peticion a un servicio y regresa la respuesta

func (*Client) SendByte added in v1.8.5

func (c *Client) SendByte(req Request) ([]byte, int, error)

SendRequest : envia una peticion de una api rest

func (*Client) SendByteV2 added in v1.9.6

func (c *Client) SendByteV2(req Request) ([]byte, map[string][]string, int, error)

SendRequest : envia una peticion de una api rest con headers response return: body headers code error

func (*Client) SendNative added in v1.9.6

func (c *Client) SendNative(req Request) (*Response, int, error)

SendNative : envia una peticion de una api rest con headers response return: *Response code error

type ConfigServer

type ConfigServer struct {
	/*Ipser : sirve para cuando este en modo produccion coloque la ip asignada al server*/
	Ipser string `ini:"ipser"`
	/*Debug : modo debug para el proyecto*/
	Debug bool `ini:"debug"`
	/*Local : habilita el modo local del servicio*/
	Local bool `ini:"local"`
	/*Puerto : Coloca el puerto del servicio*/
	Puerto int `ini:"puerto"`
	/*Protocol : protocolo del servicio*/
	Protocol string `ini:"protocol"`
	/*CertFile : certificado ssl*/
	CertFile string `ini:"certfile"`
	/*KeyFile : llave del certificado ssl*/
	KeyFile string `ini:"keyfile"`
	/*DirSSL : carpeta donde esta el certificado*/
	DirSSL string `ini:"dirssl"`
	/*Env :  carga todas las variables en variables de entorno*/
	Env bool `ini:"env"`
}

ConfigServer : configuraciones del servicio generales

func (*ConfigServer) Host

func (p *ConfigServer) Host() string

Host : envia el host del servicio

func (*ConfigServer) LoadIni

func (p *ConfigServer) LoadIni(path string) error

LoadIni : leer el archivo de configuracion del servicio esta debe ser server

func (*ConfigServer) PathCert added in v1.7.8

func (p *ConfigServer) PathCert() string

PathCert : recupera el path del certificado

func (*ConfigServer) PathKey added in v1.7.8

func (p *ConfigServer) PathKey() string

PathKey : recupera el path de la llave

func (*ConfigServer) StarServer added in v1.7.8

func (p *ConfigServer) StarServer(e *echo.Echo)

StarServer : inicia el servicio echo .

func (*ConfigServer) Valid

func (p *ConfigServer) Valid() error

Valid : valida la estructa y la configura para el servicio

type Controller

type Controller struct {
	Pets []HTTPPet
}

Controller : estructura para crear Controladores

type HTTPPet

type HTTPPet struct {
	Path string
	Pet  func(echo.Context) error
	Tip  HTTPTip
}

HTTPPet Guarda una peticion HTTP basada en ECHO

func (*HTTPPet) Valid

func (p *HTTPPet) Valid() error

Valid : Valida si la peticon es valida

type HTTPTip

type HTTPTip string

HTTPTip : especifica el tipo de peticion a elaborar

const (

	/*POST : peticion http POST*/
	POST HTTPTip = "POST"
	/*GET : peticion http GET*/
	GET HTTPTip = "GET"
	/*PUT : peticion http PUT*/
	PUT HTTPTip = "PUT"
	/*DELETE : peticion http DELETE*/
	DELETE HTTPTip = "DELETE"

	/*HTTP : protocolo http*/
	HTTP = "http"
	/*HTTPS : protocolo https*/
	HTTPS = "https"
)

func (*HTTPTip) Valid

func (p *HTTPTip) Valid() bool

Valid : Valida si un tipo de perticion es valida.

type MapMsjPet

type MapMsjPet map[string]StMsjPet

MapMsjPet : maneja el envio de mensajes con peticiones echo

func (*MapMsjPet) Send

func (p *MapMsjPet) Send(cod string, data interface{}, e echo.Context) error

Send : envia un mensaje de la peticiones pre-cargada

func (*MapMsjPet) SendFormat added in v1.7.8

func (p *MapMsjPet) SendFormat(cod string, data interface{}, e echo.Context, param ...interface{}) error

SendFormat : envia un mensaje de la peticiones pre-cargada con un formato de mensaje

type Request

type Request struct {
	Method      HTTPTip
	BaseURL     string
	Headers     map[string]string
	QueryParams map[string]string
	Body        []byte
}

Request : estructara para tener los datos del servicio

type Response

type Response struct {
	StatusCode int
	Body       string
	Headers    map[string][]string
}

Response : estructura para cargar la respuesta del servidor

func BuildResponse

func BuildResponse(res *http.Response) (*Response, error)

BuildResponse : construccion de una respuesta

func Send

func Send(request Request) (*Response, error)

Send : envia una peticion a un servicio

type RestError

type RestError struct {
	Response *Response
}

RestError : Obtiene una respuesta incorrecta al lado del servidor

type StDataEnv

type StDataEnv struct {
	Code  int         `json:"code"`
	Error string      `json:"msj"`
	Data  interface{} `json:"data"`
}

StDataEnv : Envio de datos generico

func (*StDataEnv) ResultCodeJSON

func (p *StDataEnv) ResultCodeJSON(code int, e echo.Context) error

ResultCodeJSON : envia un json de los resultado del api rest pero asignando el codigo

func (*StDataEnv) ResultFullJSON

func (p *StDataEnv) ResultFullJSON(code int, msjerr string, data interface{}, e echo.Context) error

ResultFullJSON : envia un json de los resultado del api rest pero asignando el codigo la data y el mensaje

func (*StDataEnv) ResultJSON

func (p *StDataEnv) ResultJSON(e echo.Context) error

ResultJSON : envia un json de los resultado del api rest

type StInfoPet

type StInfoPet struct {
	URL    string `json:"url"`
	Method string `json:"method"`
}

StInfoPet : envia la informacion general de la peticion

func InfPet

func InfPet(c echo.Context) StInfoPet

InfPet : captura la informacion de una peticion

func InfPetKey

func InfPetKey(c echo.Context) (StInfoPet, string)

InfPetKey : captura la informacion de una peticion y un token valido

type StInfoReq

type StInfoReq struct {
	HostOrig  string `json:"host"`
	IPRemote  string `json:"ip"`
	Browser   string `json:"browser"`
	SystemOI  string `json:"oi"`
	UserAgent string `json:"useragent"`
}

StInfoReq : Obtiene datos generales del request

func FindInfoReq

func FindInfoReq(c echo.Context) (StInfoReq, error)

FindInfoReq : Envia la informacion de un request despues de una peticion

type StMsjPet

type StMsjPet struct {
	Code int
	Msj  string
}

StMsjPet : envia un mensaje ya con el error pre-cargado para una respuesta

type UserAgent

type UserAgent struct {
	UA           string
	Mozilla      string
	Platform     string
	OS           string
	Localization string
	Browser      Browser
	Bot          bool
	Mobile       bool
	Undecided    bool
}

UserAgent : Estructura para capturar el useragent de la peticion

func New

func New(ua string) *UserAgent

New : crea un useragent

func (*UserAgent) Parse

func (p *UserAgent) Parse(ua string)

Parse : convierte el header user-agent

Jump to

Keyboard shortcuts

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