rest_api_gin_server

package
v0.0.0-...-7edcfce Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const OriginType = "rest_api"

Variables

View Source
var DefaultHttpConfigSection string = "http"
View Source
var TenancyParameter string = "tenancy"

Functions

func AuthKey

func AuthKey(key string, directKeyName ...bool) string

Types

type AuthParameterGetter

type AuthParameterGetter = func(r *Request, key string) string

type AuthParameterSetter

type AuthParameterSetter = func(r *Request, key string, value string)

type Request

type Request struct {
	api_server.RequestBase
	// contains filtered or unexported fields
}

func (*Request) CheckRequestContent

func (r *Request) CheckRequestContent(smsMessage *string, skipSms *bool) error

func (*Request) Close

func (r *Request) Close(successMessage ...string)

func (*Request) FormData

func (r *Request) FormData() map[string][]string

func (*Request) FormFile

func (r *Request) FormFile() (*multipart.FileHeader, error)

func (*Request) GetAuthParameter

func (r *Request) GetAuthParameter(authMethodProtocol string, key string, directKeyName ...bool) string

func (*Request) GetGinCtx

func (r *Request) GetGinCtx() *gin.Context

func (*Request) GetParameter

func (r *Request) GetParameter(key string) (any, bool)

func (*Request) GetRequestClientIp

func (r *Request) GetRequestClientIp() string

func (*Request) GetRequestContent

func (r *Request) GetRequestContent() []byte

func (*Request) GetRequestMethod

func (r *Request) GetRequestMethod() string

func (*Request) GetRequestPath

func (r *Request) GetRequestPath() string

func (*Request) GetRequestUserAgent

func (r *Request) GetRequestUserAgent() string

func (*Request) GetResourceId

func (r *Request) GetResourceId(resourceType string) string

func (*Request) Init

func (r *Request) Init(s *Server, ginCtx *gin.Context, ep api_server.Endpoint, fields ...logger.Fields)

func (*Request) ParseValidate

func (r *Request) ParseValidate(cmd interface{}) error

func (*Request) ParseValidateBody

func (r *Request) ParseValidateBody(cmd interface{}) error

func (*Request) ParseValidateQuery

func (r *Request) ParseValidateQuery(cmd interface{}) error

func (*Request) ResourceIds

func (r *Request) ResourceIds() map[string]string

func (*Request) Response

func (r *Request) Response() api_server.Response

func (*Request) Server

func (r *Request) Server() api_server.Server

func (*Request) SetAuthParameter

func (r *Request) SetAuthParameter(authMethodProtocol string, key string, value string, directKeyName ...bool)

func (*Request) SetParameter

func (r *Request) SetParameter(key string, value any)

func (*Request) Validate

func (r *Request) Validate(cmd interface{}) error

type Response

type Response struct {
	api_server.ResponseBase
	// contains filtered or unexported fields
}

type Server

type Server struct {
	ServerConfig
	app_context.WithAppBase
	generic_error.ErrorManagerBaseHttp
	auth.WithAuthBase
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) AddEndpoint

func (s *Server) AddEndpoint(ep api_server.Endpoint, withMultitenancy ...bool)

func (*Server) AuthParameterGetter

func (s *Server) AuthParameterGetter(authMethodProtocol string) AuthParameterGetter

func (*Server) AuthParameterSetter

func (s *Server) AuthParameterSetter(authMethodProtocol string) AuthParameterSetter

func (*Server) Config

func (s *Server) Config() interface{}

func (*Server) ConfigPoolService

func (s *Server) ConfigPoolService() pool.PoolService

func (*Server) DynamicTables

func (s *Server) DynamicTables() api_server.DynamicTables

func (*Server) GinEngine

func (s *Server) GinEngine() *gin.Engine

func (*Server) Init

func (s *Server) Init(ctx app_context.Context, auth auth.Auth, tenancyManager multitenancy.Multitenancy, configPath ...string) error

func (*Server) IsMultitenancy

func (s *Server) IsMultitenancy() bool

func (*Server) MakeResponseError

func (s *Server) MakeResponseError(gerr generic_error.Error) (int, generic_error.Error)

func (*Server) NoRoute

func (s *Server) NoRoute() gin.HandlerFunc

func (*Server) Run

func (s *Server) Run(fin background_worker.Finisher)

func (*Server) SetConfigFromPoolService

func (s *Server) SetConfigFromPoolService(service pool.PoolService, public ...bool)

func (*Server) SetPropagateAuthUser

func (s *Server) SetPropagateAuthUser(val bool)

func (*Server) SetPropagateContextId

func (s *Server) SetPropagateContextId(val bool)

func (*Server) TenancyManager

func (s *Server) TenancyManager() multitenancy.Multitenancy

func (*Server) Testing

func (s *Server) Testing() bool

type ServerConfig

type ServerConfig struct {
	api_server.ServerBaseConfig

	HOST                       string `validate:"ip" default:"127.0.0.1"`
	PORT                       uint16 `validate:"required"`
	PATH_PREFIX                string `default:"/api"`
	TRUSTED_PROXIES            []string
	VERBOSE                    bool
	VERBOSE_BODY_MAX_LENGTH    int `default:"2048"`
	ALLOW_BLOCKED_TENANCY_PATH bool
	AUTH_FROM_TENANCY_DB       bool `default:"true"`
	SHADOW_TENANCY_PATH        bool

	TENANCY_ALLOWED_IP_LIST_TAG string
	TENANCY_ALLOWED_IP_LIST     bool

	TENANCY_PARAMETER string `validate:"omitempty,alphanum"`

	DEFAULT_RESPONSE_JSON string

	FORM_SINGLE_FILE_FIELD string `default:"file"`
}

Jump to

Keyboard shortcuts

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