Documentation ¶
Index ¶
- Constants
- func GetNextHTTPRequestID() uint64
- func UrlValuesToMap(values url.Values) map[string]string
- type Config
- type HandleFunc
- type Handler
- type HandlerConfig
- type Handlers
- type Header
- type Service
- func (s *Service) EchoHandler(w http.ResponseWriter, r *http.Request)
- func (s *Service) HTTPErrorLogHandler(w http.ResponseWriter, r *http.Request)
- func (s *Service) HTTPLogHandler(w http.ResponseWriter, r *http.Request)
- func (s *Service) JWTRefreshHandler(w http.ResponseWriter, r *http.Request)
- func (s *Service) LogLevelHandler(w http.ResponseWriter, r *http.Request)
- func (s *Service) LoggerGetConfigHandler(w http.ResponseWriter, r *http.Request)
- func (s *Service) LoggerSetConfigHandler(w http.ResponseWriter, r *http.Request)
- func (s *Service) Process(ignoreBufPool bool, method string, w http.ResponseWriter, r *http.Request, ...) (myerr error)
- func (s *Service) SetHttpHandler(ctx context.Context, httpHandler interface{}) (err error)
- func (s *Service) Shutdown() (err error)
- func (s *Service) SingingHandler(w http.ResponseWriter, r *http.Request)
Constants ¶
const ( HEADER_CUSTOM_ERR_CODE = "Custom-Err-Code" HEADER_CUSTOM_ERR_CODE_SUCCESS = "0" HEADER_CUSTOM_ERR_MESSAGE = "Custom-Err-Message" HEADER_CUSTOM_ERR_CAUSE_MESSAGE = "Custom-Err-Cause-Message" HEADER_CUSTOM_ERR_TRACE = "Custom-Err-Trace" HEADER_CUSTOM_ID = "Custom-Id" HEADER_CUSTOM_REQUEST_ID = "Custom-Request-Id" HEADER_CONTENT_TYPE = "Content-Type" HEADER_CONTENT_TYPE_PLAIN_UTF8 = "text/plain; charset=utf-8" HEADER_CONTENT_TYPE_JSON_UTF8 = "application/json; charset=utf-8" HEADER_CONTENT_TYPE_XML_UTF8 = "application/xml; charset=utf-8" HEADER_CONTENT_TYPE_OCTET_STREAM = "application/octet-stream" HEADER_CONTENT_DISPOSITION = "Content-Disposition" HEADER_CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding" HEADER_CONTENT_TRANSFER_ENCODING_BINARY = "binary" HEADER_LOG_LEVEL_GLOBALLOGFILTER = "Log-Level-globalLogFilter" HEADER_LOG_HTTP_TRAFFIC_STATUS = "Log-HTTP-Traffic-Status" HEADER_LOG_HTTP_TRAFFIC_TYPE = "Log-HTTP-Traffic-Type" HEADER_LOG_ERROR_TO_HTTP_TYPE = "Log-Error-To-HTTP-Type" AUTH_TYPE_NONE = "NONE" AUTH_TYPE_INTERNAL = "INTERNAL" AUTH_TYPE_MSAD = "MSAD" )
Variables ¶
This section is empty.
Functions ¶
func GetNextHTTPRequestID ¶
func GetNextHTTPRequestID() uint64
GetNextHTTPRequestID - запросить номер следующего HTTP запроса
Types ¶
type Config ¶
type Config struct { JwtKeyStr string `yaml:"-" json:"-"` // JWT secret key JwtKey []byte `yaml:"-" json:"-"` // JWT secret key HTTPUser string `yaml:"-" json:"-"` // пользователь для HTTP Basic Authentication передается через командую строку HTTPPass string `yaml:"-" json:"-"` // пароль для HTTP Basic Authentication передается через командую строку AuthType string `yaml:"auth_type" json:"auth_type"` // Authentication type NONE, INTERNAL, MSAD MaxBodyBytes int `yaml:"max_body_bytes" json:"max_body_bytes"` // HTTP max body bytes - default 0 - unlimited UseHSTS bool `yaml:"use_hsts" json:"use_hsts"` // use HTTP Strict Transport Security UseJWT bool `yaml:"use_jwt" json:"use_jwt"` // use JSON web token (JWT) JWTExpiresAt int `yaml:"jwt_expires_at" json:"jwt_expires_at"` // JWT expiry time in seconds - 0 without restriction MSADServer string `yaml:"msad_server" json:"msad_server"` // MS Active Directory server MSADPort int `yaml:"msad_port" json:"msad_port"` // MS Active Directory Port MSADBaseDN string `yaml:"msad_base_dn" json:"msad_base_dn"` // MS Active Directory BaseDN MSADSecurity int `yaml:"msad_security" json:"msad_security"` // MS Active Directory Security: SecurityNone, SecurityTLS, SecurityStartTLS UseBufPool bool `yaml:"use_buf_pool" json:"use_buf_pool"` // use byte polling for JSON -> HTTP BufPooledSize int `yaml:"buf_pooled_size" json:"buf_pooled_size"` // recommended size of polling for JSON -> HTTP BufPooledMaxSize int `yaml:"buf_pooled_max_size" json:"buf_pooled_max_size"` // max size of polling for JSON -> HTTP HTTPErrorLogHeader bool `yaml:"log_error_to_http_header" json:"log_error_to_http_header"` // log any error to HTTP response header HTTPErrorLogBody bool `yaml:"log_error_to_http_body" json:"log_error_to_http_body"` // log any error to HTTP response body HTTPHeaderMaxSize int `yaml:"http_header_max_size" json:"http_header_max_size"` // max size HTTP header element - use for out response Handlers map[string]HandlerConfig `yaml:"handlers" json:"handlers"` // HTTP handler configurations // конфигурация вложенных сервисов BytesPoolCfg bytespool.Config `yaml:"-" json:"-"` // конфигурация bytesPool }
Config represent HTTP Service configurations
type HandleFunc ¶
type HandleFunc func(http.ResponseWriter, *http.Request)
type Handler ¶
type Handler struct { Path string HandlerFunc http.HandlerFunc Method string }
Handler represent HTTP handler
type HandlerConfig ¶
type HandlerConfig struct { Enabled bool `yaml:"enabled" json:"enabled"` // Признак включен ли сервис Application string `yaml:"application" json:"application"` // Приложение к которому относится сервис, например, app Module string `yaml:"module" json:"module,omitempty"` // Модуль к которому относится сервис, например, calculator Service string `yaml:"service" json:"service,omitempty"` // Имя сервиса, например, berth Version string `yaml:"version" json:"version,omitempty"` // Версия сервиса FullPath string `yaml:"full_path" json:"full_path,omitempty"` // URI сервиса /Application.Module.Service.APIVersion или /Application/APIVersion/Module/Service Params string `yaml:"params" json:"params,omitempty"` // Параметры сервиса с виде {id:[0-9]+} Method string `yaml:"method" json:"method,omitempty"` // HTTP метод: GET, POST, ... HandlerName string `yaml:"handler_name" json:"handler_name,omitempty"` // Имя функции обработчика }
HandlerConfig represent HTTP handler configurations
type Service ¶
type Service struct { Handlers Handlers // список обработчиков // contains filtered or unexported fields }
Service represent HTTP service
func New ¶
func New(ctx context.Context, cfg *Config, httpLogger *_httplog.Logger) (*Service, *_httplog.Logger, error)
New create new HTTP service
func (*Service) EchoHandler ¶
func (s *Service) EchoHandler(w http.ResponseWriter, r *http.Request)
EchoHandler handle echo page with request header and body
func (*Service) HTTPErrorLogHandler ¶
func (s *Service) HTTPErrorLogHandler(w http.ResponseWriter, r *http.Request)
HTTPErrorLogHandler handle loging error into HTTP response
func (*Service) HTTPLogHandler ¶
func (s *Service) HTTPLogHandler(w http.ResponseWriter, r *http.Request)
HTTPLogHandler handle HTTP log mode
func (*Service) JWTRefreshHandler ¶
func (s *Service) JWTRefreshHandler(w http.ResponseWriter, r *http.Request)
JWTRefreshHandler handle renew JWT
func (*Service) LogLevelHandler ¶
func (s *Service) LogLevelHandler(w http.ResponseWriter, r *http.Request)
LogLevelHandler handle logging filter
func (*Service) LoggerGetConfigHandler ¶
func (s *Service) LoggerGetConfigHandler(w http.ResponseWriter, r *http.Request)
LoggerGetConfigHandler Сервис отвечает за считывание в YAML формате конфигурационных настроек logger
func (*Service) LoggerSetConfigHandler ¶
func (s *Service) LoggerSetConfigHandler(w http.ResponseWriter, r *http.Request)
LoggerSetConfigHandler Сервис отвечает за установку в YAML формате конфигурационных настроек logger
func (*Service) Process ¶
func (s *Service) Process(ignoreBufPool bool, method string, w http.ResponseWriter, r *http.Request, fn func(ctx context.Context, requestBuf []byte, buf []byte) ([]byte, Header, int, error)) (myerr error)
Process - represent server common task in Process incoming HTTP request
func (*Service) SetHttpHandler ¶
SetHttpHandler create HTTP handlers
func (*Service) SingingHandler ¶
func (s *Service) SingingHandler(w http.ResponseWriter, r *http.Request)
SingingHandler handle authentication and creating JWT