ahttp

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COOKIE_FLASH_FORGOT_LOGIN   = azb.ZBType("fm-forgot-login")
	COOKIE_FLASH_RESET_PASSWORD = azb.ZBType("fm-reset-password")
)

Constants for cookie names used in flash messages.

View Source
const (
	PAGINATENAV_CONTROL_LABEL_RESULTS = azb.ZBType("label-results") // Label for results.
	PAGINATENAV_CONTROL_LABEL_COUNT   = azb.ZBType("label-count")   // Label for count.
	PAGINATENAV_CONTROL_SHOW_PER_PAGE = azb.ZBType("show-per-page") // Control to show per page options.
	PAGINATENAV_CONTROL_NAVLINKS      = azb.ZBType("nav-links")     // Navigation links.
)

Constants for pagination navigation control types.

View Source
const (
	PUI_DIRECTION_LEFT         azb.ZBType = "left"
	PUI_DIRECTION_RIGHT        azb.ZBType = "right"
	PUI_SIDEBAR_STATUS_OPEN    azb.ZBType = "open"
	PUI_SIDEBAR_STATUS_CLOSE   azb.ZBType = "close"
	PUI_SIDEBAR_STATUS_DISMISS azb.ZBType = "dismiss"
)
View Source
const MIMETYPE_JSON_NOUTF = `application/json`

MIMETYPE_JSON_NOUTF is used to specify the JSON MIME type without character set encoding.

Variables

View Source
var ISON_UNITTESTS_UPDOWN_SECRET = ""

ISON_UNITTESTS_UPDOWN_SECRET is the secret key required to authorize a unit test shutdown.

View Source
var ISON_UNITTESTS_WAIT_USER_SHUTDOWN = 0

ISON_UNITTESTS_WAIT_USER_SHUTDOWN specifies the wait time in seconds for user-initiated service shutdown during unit tests.

Functions

func APIJSONSendROB

func APIJSONSendROB(c echo.Context, data interface{}) error

APIJSONSendROB sends a JSON response with data wrapped in an ROB record. It is used to send a successful response (http.StatusOK) with additional data. Parameters: - c: The echo.Context object. - data: The data to be included in the response.

func APIJSONSendROBError

func APIJSONSendROBError(c echo.Context, err error) error

APIJSONSendROBError sends a JSON response with a status of "OK" (http.StatusOK) and an ROB error type. It uses APIJSONSendROBStatusWithOptions to return a response with an error message. Parameters: - c: The echo.Context object, which carries the request and response context. - err: The error object that will be included in the response as the error detail.

func APIJSONSendROBErrorWithCode

func APIJSONSendROBErrorWithCode(c echo.Context, code int, err error) error

APIJSONSendROBErrorWithCode sends a JSON response with a custom HTTP status code and an ROB error type. It allows specifying the HTTP status code in the response, useful for sending different error codes. Parameters: - c: The echo.Context object. - code: The custom HTTP status code to be returned (e.g., 400 for Bad Request). - err: The error object that will be included in the response as the error detail.

func APIJSONSendROBInfoOk

func APIJSONSendROBInfoOk(c echo.Context) error

APIJSONSendROBInfoOk sends a JSON response with an "OK" status and ROB info type. It is a convenience function for sending a simple "OK" message in an ROB response. Parameters: - c: The echo.Context object.

func APIJSONSendROBInfoRecs

func APIJSONSendROBInfoRecs(c echo.Context, status string, recs interface{}) error

APIJSONSendROBInfoRecs sends a JSON response with a status of http.StatusOK (200) and records wrapped in an ROB record. It is used to send a response with both a custom status message and additional data records. Parameters: - c: The echo.Context object. - status: The custom status message. - recs: The records to be included in the response.

func APIJSONSendROBInfoStatus

func APIJSONSendROBInfoStatus(c echo.Context, status string) error

APIJSONSendROBInfoStatus sends a JSON response with a status of http.StatusOK (200) and a custom status message. It includes a custom status message in the ROB response. Parameters: - c: The echo.Context object. - status: The custom status message to be included in the response.

func APIJSONSendROBStatusWithOptions

func APIJSONSendROBStatusWithOptions(c echo.Context, code int, statusType arob.ROBType, status string, data interface{}, err error) error

APIJSONSendROBStatusWithOptions is a utility function that sends a JSON response with flexible options. It allows sending responses with different status codes, ROB types, status messages, data, and error details. Parameters: - c: The echo.Context object. - code: The HTTP status code (e.g., 200 for OK, 400 for Bad Request). - statusType: The type of ROB message (e.g., ROBTYPE_INFO, ROBTYPE_ERROR). - status: The custom status message (if empty, it defaults to the standard status text for the HTTP code). - data: Optional data to include in the response. - err: Optional error object to include in the response (used if non-nil).

func APIJSONSendROBWithCode

func APIJSONSendROBWithCode(c echo.Context, code int, data interface{}) error

APIJSONSendROBWithCode sends a JSON response with a custom HTTP status code and data wrapped in an ROB record. This allows specifying a custom status code for the response. Parameters: - c: The echo.Context object. - code: The custom HTTP status code. - data: The data to be included in the response.

func DefaultHTTPErrorHandler

func DefaultHTTPErrorHandler(options IHTTPErrorHandler)

DefaultHTTPErrorHandler handles HTTP errors by sending a JSON response with the status code. It is a variation of echo.DefaultHTTPErrorHandler.

func DetectMimeTypeSendError

func DetectMimeTypeSendError(c echo.Context, code int, err error) error

DetectMimeTypeSendError sends an error message with the appropriate MIME type. If the code is not provided, it defaults to http.StatusInternalServerError.

func DetectMimeTypeSendErrorWithCode

func DetectMimeTypeSendErrorWithCode(c echo.Context, code int, err error) error

DetectMimeTypeSendErrorWithCode sends an error message with the appropriate MIME type and status code.

func DetectMimeTypeSendMessage

func DetectMimeTypeSendMessage(c echo.Context, code int, message string, isSysError bool) error

DetectMimeTypeSendMessage sends a message with the appropriate MIME type. If the code is not provided, it defaults to http.StatusOK.

func DetectMimeTypeSendMessageWithCode

func DetectMimeTypeSendMessageWithCode(c echo.Context, code int, message string, isSysError bool) error

DetectMimeTypeSendMessageWithCode sends a message with the appropriate MIME type and status code.

func DumpHeaderRequest

func DumpHeaderRequest(req *http.Request, dumpBody bool)

DumpHeaderRequest prints the HTTP request headers and body for debugging purposes.

func DumpHeaderResponse

func DumpHeaderResponse(res *http.Response, dumpBody bool)

DumpHeaderResponse prints the HTTP response headers and body for debugging purposes.

func ForceRedirectRawQuery

func ForceRedirectRawQuery(c echo.Context, targetUrl string) error

ForceRedirectRawQuery redirects the client to the target URL, preserving the raw query parameters.

func ForceRedirectRequestToBase64

func ForceRedirectRequestToBase64(c echo.Context, targetUrl string) error

ForceRedirectRequestToBase64 redirects the client to the target URL with the request URL encoded in base64.

func GetIsOnUnitTests

func GetIsOnUnitTests() bool

GetIsOnUnitTests checks if unit tests are configured to wait for user shutdown.

func GetIsOnUnitTestsHasSecret

func GetIsOnUnitTestsHasSecret() bool

GetIsOnUnitTestsHasSecret checks if a secret key is set for unit test shutdown.

func GetPSCConstantsMapDefault

func GetPSCConstantsMapDefault() map[string]string

func GetRequestContentType

func GetRequestContentType(c echo.Context) string

GetRequestContentType retrieves the Content-Type header from the request.

func HasContentType

func HasContentType(r *http.Request, mimetype string) bool

HasContentType checks if the request has the specified MIME type in its Content-Type header.

func InitializePSC

func InitializePSC(controller IPageSessionController)

InitializePSC initializes the global instance of IPageSessionController. This function should be called once at program startup.

func InitializeSCS

func InitializeSCS(mySCS *scs.SessionManager)

InitializeSCS initializes the global instance of IPageSessionController. This function should be called once at program startup.

func IsBot

func IsBot(ua *useragent.UserAgent) bool

IsBot checks if the user agent represents a search engine crawler or bot.

func IsMobileDevice

func IsMobileDevice(ua *useragent.UserAgent) bool

IsMobileDevice checks if the user agent represents a mobile device.

func IsRequestContentType

func IsRequestContentType(c echo.Context, checkMimeType CheckMIMEType) bool

IsRequestContentType checks if the request's Content-Type matches the specified CheckMIMEType.

func IsSpecificBrowser

func IsSpecificBrowser(ua *useragent.UserAgent, browserName string) bool

IsSpecificBrowser checks if the user agent represents a specific browser.

func JoinUrl

func JoinUrl(urlRoot string, urlPath string) string

JoinUrl concatenates the root URL with a path, ensuring proper formatting.

func NewRHPageData

func NewRHPageData(activeURL string, title string, us asessions.ILoginSessionPerm, data interface{}) map[string]interface{}

func NewRHPageDataPaginate

func NewRHPageDataPaginate(activeURL string, title string, us asessions.ILoginSessionPerm, paginate azb.IPaginate, data interface{}) map[string]interface{}

func ParseUserAgentString

func ParseUserAgentString(uaString string) (ua *useragent.UserAgent, deviceName string)

ParseUserAgentString parses the user agent string and returns the useragent.UserAgent object and a descriptive device name.

func PrettyPrint

func PrettyPrint(ua *useragent.UserAgent) string

PrettyPrint returns a formatted string with the user agent details.

func RHBind

func RHBind(c echo.Context, din interface{}) error

RHBind binds the request body to the provided data interface for POST requests.

func RHBindList

func RHBindList(c echo.Context, din azb.IDINPaginate) error

RHBindList binds the request body to the provided data interface and validates it.

func RHBindListPostOnly

func RHBindListPostOnly(c echo.Context, din azb.IDINPaginate) error

RHBindListPostOnly binds the request body to the provided data interface only for POST requests.

func RHBindListQuery

func RHBindListQuery(c echo.Context, din azb.IDINPaginate) error

RHBindListQuery binds query parameters to the provided data interface and validates it.

func RHBindNopCloser

func RHBindNopCloser(c echo.Context, din interface{}) error

RHBindNopCloser binds the request body to the provided data interface for POST requests and restores the request body to allow for subsequent reads.

func RHStatus

func RHStatus(c echo.Context, code int, routeId HttpRouteId, newPD NewPageData) error

RHStatus returns http.StatusOK. If JSON is detected, it automatically creates and returns a rob error object.

func RedirectCheckJSON

func RedirectCheckJSON(c echo.Context, url string) error

RedirectCheckJSON redirects the client to the specified URL or returns a JSON response with the URL if the request is JSON.

func RedirectFlashMessage

func RedirectFlashMessage(c echo.Context, cookieName azb.ZBType, fmData *FlashMessageData, targetUrl string) error

RedirectFlashMessage sets a flash message cookie and redirects the user.

func ResetUserSessionWithRedirect

func ResetUserSessionWithRedirect(c echo.Context, manager *scs.SessionManager, urlTarget string) error

ResetUserSessionWithRedirect clears the user session and redirects to the given URL.

func ResetUserSessionWithRedirectJSONMessage

func ResetUserSessionWithRedirectJSONMessage(c echo.Context, manager *scs.SessionManager, urlTarget string, message arob.ROBMessage) error

ResetUserSessionWithRedirectJSONMessage clears the user session and returns a JSON message or redirects.

func SCS

func SCS() *scs.SessionManager

SCS returns the global instance of *scs.SessionManager.

func SetAuthManager

func SetAuthManager(authManager IAuthManager)

SetAuthManager initializes the global instance of IAuthManager.

func WaitForServerStartEcho

func WaitForServerStartEcho(e *echo.Echo, errChan <-chan error, isTLS bool, retryInterval time.Duration) error

WaitForServerStartEcho waits for an Echo server to start using channels. It checks the server's listener address to determine if the server has started. The function now accepts a retry interval parameter.

func WaitForServerStartPing

func WaitForServerStartPing(urlRequest string, expectedResults string, pingTimeOutSeconds int, retryInterval time.Duration) error

WaitForServerStartPing sends HTTP GET requests to the specified URL until the expected response is received or it times out. The function now accepts a retry interval parameter and includes logging.

Types

type AuthenticateProvisioner

type AuthenticateProvisioner struct {
	UrlNoLogin      string // URL to redirect when no login is detected
	UrlInvalidPerms string // URL to redirect when invalid permissions are detected
	// contains filtered or unexported fields
}

AuthenticateProvisioner holds URLs for redirection in case of authentication issues and provides thread-safe access to these URLs.

func (*AuthenticateProvisioner) GetUrlInvalidPerms

func (ap *AuthenticateProvisioner) GetUrlInvalidPerms() string

GetUrlInvalidPerms safely returns the URL to redirect when invalid permissions are detected.

func (*AuthenticateProvisioner) GetUrlNoLogin

func (ap *AuthenticateProvisioner) GetUrlNoLogin() string

GetUrlNoLogin safely returns the URL to redirect when no login is detected.

func (*AuthenticateProvisioner) LogAuthError

func (ap *AuthenticateProvisioner) LogAuthError(c echo.Context, err error)

LogAuthError logs an authentication error. This method is a placeholder and should be implemented.

type CheckMIMEType

type CheckMIMEType int

CheckMIMEType defines an enumeration for different MIME types to check against.

const (
	// CHECK_MIME_TYPE_NONE indicates no MIME type is expected.
	CHECK_MIME_TYPE_NONE CheckMIMEType = iota
	// CHECK_MIME_TYPE_JSON indicates a JSON MIME type.
	CHECK_MIME_TYPE_JSON
	// CHECK_MIME_TYPE_XML indicates an XML MIME type.
	CHECK_MIME_TYPE_XML
	// CHECK_MIME_TYPE_HTML indicates an HTML MIME type.
	CHECK_MIME_TYPE_HTML
)

type CreateRouteHandler

type CreateRouteHandler func(route IRoute) echo.HandlerFunc

CreateRouteHandler defines a function type that takes an IRoute and returns an echo.HandlerFunc. This allows for flexible handling of route creation with custom logic.

func CreateRouteHandlerByEchoHandlerFunc

func CreateRouteHandlerByEchoHandlerFunc(handler echo.HandlerFunc) CreateRouteHandler

CreateRouteHandlerByEchoHandlerFunc wraps a given echo.HandlerFunc into a CreateRouteHandler type. It panics if the handler is nil, ensuring a valid handler is always provided.

type FlashMessage

type FlashMessage struct {
	Title   string `json:"title" form:"title"`     // The title of the flash message.
	Lead    string `json:"lead" form:"lead"`       // The lead text of the flash message.
	Message string `json:"message" form:"message"` // The main message content.
}

FlashMessage represents the structure of a flash message.

type FlashMessageData

type FlashMessageData struct {
	Path     string `json:"path,omitempty" form:"path"`         // The path where the flash message originated.
	Action   string `json:"action,omitempty" form:"action"`     // The action that triggered the flash message.
	Username string `json:"username,omitempty" form:"username"` // The username involved in the action.
}

FlashMessageData holds the data to be displayed in a flash message to the user.

type HTTPErrorHandlerBase

type HTTPErrorHandlerBase struct {
	// contains filtered or unexported fields
}

HTTPErrorHandlerBase provides a basic implementation of IHTTPErrorHandler.

func NewHTTPErrorHandlerBase

func NewHTTPErrorHandlerBase(err error, c echo.Context, logger echo.Logger, isOnDebug bool) *HTTPErrorHandlerBase

NewHTTPErrorHandlerBase creates a new instance of HTTPErrorHandlerBase.

func (*HTTPErrorHandlerBase) GetContext

func (he *HTTPErrorHandlerBase) GetContext() echo.Context

func (*HTTPErrorHandlerBase) GetErr

func (he *HTTPErrorHandlerBase) GetErr() error

Getters and setters for HTTPErrorHandlerBase.

func (*HTTPErrorHandlerBase) GetHttpCode

func (he *HTTPErrorHandlerBase) GetHttpCode() int

func (*HTTPErrorHandlerBase) GetHttpMessage

func (he *HTTPErrorHandlerBase) GetHttpMessage() string

func (*HTTPErrorHandlerBase) GetIsOnDebug

func (he *HTTPErrorHandlerBase) GetIsOnDebug() bool

func (*HTTPErrorHandlerBase) GetLogger

func (he *HTTPErrorHandlerBase) GetLogger() echo.Logger

func (*HTTPErrorHandlerBase) SetHttpCode

func (he *HTTPErrorHandlerBase) SetHttpCode(httpCode int)

func (*HTTPErrorHandlerBase) SetHttpMessage

func (he *HTTPErrorHandlerBase) SetHttpMessage(httpMessage string)

type HTTPErrorHandlerDefault

type HTTPErrorHandlerDefault struct {
	HTTPErrorHandlerBase
	// contains filtered or unexported fields
}

HTTPErrorHandlerDefault is a default error handler that requires a PSC and uses fixed pages, like "status.gohtml". This struct may be too inflexible to your needs. If this is the case, adapt it in your higher-level application.

func NewHTTPErrorHandlerDefault

func NewHTTPErrorHandlerDefault(err error, c echo.Context, logger echo.Logger, isOnDebug bool, newPD NewPageData) *HTTPErrorHandlerDefault

func (*HTTPErrorHandlerDefault) HandleResponse

func (he *HTTPErrorHandlerDefault) HandleResponse() error

type HttpMethod

type HttpMethod string

HttpMethod represents the HTTP methods used in requests.

const (
	HTTPMETHOD_GET    HttpMethod = "GET"
	HTTPMETHOD_POST   HttpMethod = "POST"
	HTTPMETHOD_PUT    HttpMethod = "PUT"
	HTTPMETHOD_DELETE HttpMethod = "DELETE"
	HTTPMETHOD_PATCH  HttpMethod = "PATCH"
)

Constants for the various HTTP methods.

func (HttpMethod) IsEmpty

func (hm HttpMethod) IsEmpty() bool

IsEmpty checks if the HttpMethod is empty after trimming whitespace.

func (HttpMethod) String

func (hm HttpMethod) String() string

String converts the HttpMethod to a string.

func (HttpMethod) ToStringTrimUpper

func (hm HttpMethod) ToStringTrimUpper() string

ToStringTrimUpper trims whitespace from the HttpMethod and converts it to uppercase.

func (HttpMethod) TrimSpace

func (hm HttpMethod) TrimSpace() HttpMethod

TrimSpace returns a new HttpMethod with leading and trailing whitespace removed.

func (HttpMethod) TrimSpaceToUpper

func (hm HttpMethod) TrimSpaceToUpper() HttpMethod

TrimSpaceToUpper trims whitespace from the HttpMethod and converts it to uppercase.

type HttpMethods

type HttpMethods []HttpMethod

HttpMethods is a slice of HttpMethod.

func (HttpMethods) Find

func (hms HttpMethods) Find(target HttpMethod) HttpMethod

Find searches for a target HttpMethod in the slice and returns it if found.

func (HttpMethods) Has

func (hms HttpMethods) Has(target HttpMethod) bool

Has checks if a target HttpMethod is present in the slice.

type HttpRouteId

type HttpRouteId string

HttpRouteId is a custom type for route identifiers.

const (
	RPAGE_ROOT                     HttpRouteId = "RPAGE_ROOT"
	RPAGE_ROOT_HOME                HttpRouteId = "RPAGE_ROOT_HOME"
	RPAGE_ROOT_NOT_FOUND           HttpRouteId = "RPAGE_ROOT_NOT_FOUND"
	RPAGE_ROOT_SERVICE_UNAVAILABLE HttpRouteId = "RPAGE_ROOT_SERVICE_UNAVAILABLE"
	RPAGE_ROOT_FORBIDDEN           HttpRouteId = "RPAGE_ROOT_FORBIDDEN"
	RPAGE_US_ACTION                HttpRouteId = "RPAGE_US_ACTION"
	RPAGE_US_ACTION_POST           HttpRouteId = "RPAGE_US_ACTION_POST"
	RPAGE_US_ACTION_UNAVAILABLE    HttpRouteId = "RPAGE_US_ACTION_UNAVAILABLE"
	RPAGE_ROOT_MAINTENANCE         HttpRouteId = "RPAGE_ROOT_MAINTENANCE"
	ROUTE_REDIRECT_DEFAULT         HttpRouteId = "ROUTE_REDIRECT_DEFAULT"
	ROUTE_REDIRECT_AUTH_ERROR      HttpRouteId = "ROUTE_REDIRECT_AUTH_ERROR"
	RPAGE_LOGIN                    HttpRouteId = "RPAGE_LOGIN"
	RPAGE_LOGIN_SUBMIT             HttpRouteId = "RPAGE_LOGIN_SUBMIT"
	RPAGE_LOGOUT                   HttpRouteId = "RPAGE_LOGOUT"
	RPAGE_FORGOT_LOGIN             HttpRouteId = "RPAGE_FORGOT_LOGIN"
	RPAGE_FORGOT_LOGIN_SUBMIT      HttpRouteId = "RPAGE_FORGOT_LOGIN_SUBMIT"
	RPAGE_FLASH                    HttpRouteId = "RPAGE_FLASH"
	RPAGE_JWT_LINK                 HttpRouteId = "RPAGE_JWT_LINK"
	RPAGE_LEGAL_SUMMARY            HttpRouteId = "RPAGE_LEGAL_SUMMARY"
	RPAGE_LEGAL_TERMS              HttpRouteId = "RPAGE_LEGAL_TERMS"
	RPAGE_LEGAL_PRIVACY            HttpRouteId = "RPAGE_LEGAL_PRIVACY"
	RPAGE_LEGAL_COOKIES            HttpRouteId = "RPAGE_LEGAL_COOKIES"
	RPAGE_LEGAL_DMCA               HttpRouteId = "RPAGE_LEGAL_DMCA"
	RPAGE_SYSTEM_SGLOBALS          HttpRouteId = "RPAGE_SYSTEM_SGLOBALS"
	RPAGE_SYSTEM_SGLOBALS_MOD      HttpRouteId = "RPAGE_SYSTEM_SGLOBALS_MOD"
	RPAGE_SYSTEM_SDOCS             HttpRouteId = "RPAGE_SYSTEM_SDOCS"
	RPAGE_SYSTEM_SDOCS_MOD         HttpRouteId = "RPAGE_SYSTEM_SDOCS_MOD"
	RPAGE_SYSTEM_SMAILERS          HttpRouteId = "RPAGE_SYSTEM_SMAILERS"
	RPAGE_SYSTEM_SMAILERS_MOD      HttpRouteId = "RPAGE_SYSTEM_SMAILERS_MOD"
	RPAGE_CONTACT_CDESK            HttpRouteId = "RPAGE_CONTACT_CDESK"
	RPAGE_CONTACT_CDESK_MOD        HttpRouteId = "RPAGE_CONTACT_CDESK_MOD"
	RPAGE_USER_DASHBOARD           HttpRouteId = "RPAGE_USER_DASHBOARD"
	RPAGE_USER_DASHBOARD_MOD       HttpRouteId = "RPAGE_USER_DASHBOARD_MOD"
	RPAGE_USER_PROFILE             HttpRouteId = "RPAGE_USER_PROFILE"
	RPAGE_USER_PROFILE_MOD         HttpRouteId = "RPAGE_USER_PROFILE_MOD"
	ROUTE_REDIRECT_CUSTOM          HttpRouteId = "ROUTE_REDIRECT_CUSTOM"
	RAPI_PING                      HttpRouteId = "RAPI_PING"
	RAPI_UNITTEST_SHUTDOWNS        HttpRouteId = "RAPI_UNITTEST_SHUTDOWNS"
)

Define constants for various route identifiers using the NAME TYPE = VALUE format.

func ExtractHttpRouteId

func ExtractHttpRouteId(name string) (HttpRouteId, bool)

ExtractHttpRouteId extracts the HttpRouteId from a string if it is prefixed with "hrt:".

func (HttpRouteId) IsEmpty

func (rt HttpRouteId) IsEmpty() bool

IsEmpty checks if the HttpRouteId is empty after trimming whitespace.

func (HttpRouteId) String

func (rt HttpRouteId) String() string

String converts the HttpRouteId to a string.

func (HttpRouteId) TrimSpace

func (rt HttpRouteId) TrimSpace() HttpRouteId

TrimSpace returns a new HttpRouteId with leading and trailing whitespace removed.

type HttpRouteIdMap

type HttpRouteIdMap map[HttpRouteId]string

HttpRouteIdMap defines a map that associates HttpRouteId keys with URL strings.

func NewRouteRedirectDefaults

func NewRouteRedirectDefaults() HttpRouteIdMap

NewRouteRedirectDefaults creates a new HttpRouteIdMap with default route redirects.

type HttpRouteMap

type HttpRouteMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

HttpRouteMap is a struct that associates HttpRouteId with an IRoute value.

func (*HttpRouteMap) DeleteRoute

func (m *HttpRouteMap) DeleteRoute(key HttpRouteId) error

DeleteRoute deletes a route.

func (*HttpRouteMap) Get

func (m *HttpRouteMap) Get(key HttpRouteId) IRoute

Get retrieves the IRoute associated with the given HttpRouteId. It uses a read lock to allow concurrent read access.

func (*HttpRouteMap) GetRoutesArray

func (m *HttpRouteMap) GetRoutesArray() []IRoute

GetRoutesArray returns an array of IRoute objects sorted by their index.

func (*HttpRouteMap) GetUrlInvalidPerms

func (m *HttpRouteMap) GetUrlInvalidPerms() string

GetUrlInvalidPerms safely gets the urlInvalidPerms field from the global instance.

func (*HttpRouteMap) GetUrlNoLogin

func (m *HttpRouteMap) GetUrlNoLogin() string

GetUrlNoLogin safely gets the urlNoLogin field from the global instance.

func (*HttpRouteMap) LogAuthError

func (m *HttpRouteMap) LogAuthError(c echo.Context, err error)

LogAuthError logs the authentication or authorization error.

func (*HttpRouteMap) MustUrl

func (m *HttpRouteMap) MustUrl(key HttpRouteId) string

MustUrl retrieves the URL associated with the given HttpRouteId or returns urlHome if not found.

func (*HttpRouteMap) MustUrlElseDash

func (m *HttpRouteMap) MustUrlElseDash(key HttpRouteId) string

MustUrlElseDash retrieves the URL associated with the given HttpRouteId or returns urlDash if not found.

func (*HttpRouteMap) MustUrlElseIsLogin

func (m *HttpRouteMap) MustUrlElseIsLogin(key HttpRouteId, isLoggedIn bool) string

MustUrlElseIsLogin retrieves the URL associated with the given HttpRouteId or returns urlHome or urlDash based on login status.

func (*HttpRouteMap) MustUrlRedirect

func (m *HttpRouteMap) MustUrlRedirect(isLoggedIn bool) string

MustUrlRedirect returns urlDash if the user is logged in, otherwise returns urlHome.

func (*HttpRouteMap) RouteExists

func (m *HttpRouteMap) RouteExists(key HttpRouteId) bool

RouteExists checks if a route exists.

func (*HttpRouteMap) Set

func (m *HttpRouteMap) Set(key HttpRouteId, value IRoute) error

Set sets the IRoute for a given HttpRouteId in the map, ensuring the path is not set by the key. It uses a write lock to prevent concurrent writes.

func (*HttpRouteMap) SetRouteMapSpecials

func (m *HttpRouteMap) SetRouteMapSpecials(rHome HttpRouteId, rDash HttpRouteId, rNoLogin HttpRouteId, rInvalidPerms HttpRouteId) error

SetRouteMapSpecials sets urlNoLogin and urlInvalidPerms. It uses a write lock to prevent concurrent writes and ensure atomicity.

type IAuthManager

type IAuthManager interface {
	//NewLoginUserSession(username asessions.Username, password string) (*asessions.UserSessionPerm, error)
	NewLoginUserSession(username auser.Username, authType string, secret string) (*asessions.UserSessionPerm, error)
}

func AUTHMANAGER

func AUTHMANAGER() IAuthManager

AUTHMANAGER returns the global instance of IAuthManager.

type IHTTPErrorHandler

type IHTTPErrorHandler interface {
	GetErr() error
	GetContext() echo.Context
	GetLogger() echo.Logger
	GetIsOnDebug() bool
	GetHttpCode() int
	GetHttpMessage() string
	SetHttpCode(httpCode int)
	SetHttpMessage(httpMessage string)
	HandleResponse() error // Implementation required at a higher level.
}

IHTTPErrorHandler defines the interface for handling HTTP errors.

type IPageSessionController

type IPageSessionController interface {
	IVersionProvider
	IUrlProvider
	ISiteConfig
	WRC() IWebRouteController
	// Permissions methods
	HasPerm(us asessions.ILoginSessionPerm, target asessions.Perm) bool
	HasPermS(us asessions.ILoginSessionPerm, keyPermValue string) bool
	HasPermSV(us asessions.ILoginSessionPerm, key string, value string) bool
	HasPermB(us asessions.ILoginSessionPerm, keyBits string) bool
	HasPermBV(us asessions.ILoginSessionPerm, key string, bit int) bool
	HasPermSet(us asessions.ILoginSessionPerm, target asessions.PermSet) bool
	HasPermKeyValueConst(us asessions.ILoginSessionPerm, key string, value string) bool
}

func PSC

PSC returns the global instance of IPageSessionController.

type IRoute

type IRoute interface {
	GetRouteId() HttpRouteId         // Returns the unique identifier of the route.
	GetMethod() HttpMethod           // Returns the HTTP method (GET, POST, etc.) associated with the route.
	GetPath() string                 // Returns the URL path of the route.
	GetPerms() asessions.PermSet     // Returns the permissions required to access the route.
	GetRouteNotFoundId() HttpRouteId // Returns the identifier of the route to use when the current route is not found.
	GetIndexAdded() int
	CreateHandler() echo.HandlerFunc
	GetWhitelist() string
}

IRoute defines the interface for route-related information. It is implemented by types that represent specific routes within the application.

type IRouteMap

type IRouteMap map[HttpRouteId]IRoute

IRouteMap is a map that associates route IDs with their corresponding IRoute interface.

type IRoutes

type IRoutes []IRoute

IRoutes is a slice of IRoute interfaces.

func (IRoutes) ToMap

func (rts IRoutes) ToMap() IRouteMap

ToMap converts a slice of IRoute interfaces into a map keyed by the route ID.

type ISiteConfig

type ISiteConfig interface {
	GetMinExtension() string
	GetIsPrivateSite() bool
	GetPublicUrl() string
	GetConst(target string) string
	GetPublicNetUrl() *anetwork.NetURL
}

type IUrlProvider

type IUrlProvider interface {
	RouteExists(httpRouteId HttpRouteId) bool
	MustUrl(httpRouteId HttpRouteId) string
	IfActiveUrlThenValue(activeUrl string, targetUrlKey HttpRouteId, value string) string
}

type IVersionProvider

type IVersionProvider interface {
	GetAppVersion() *aapp.AppVersion
}

type IWebRouteController

type IWebRouteController interface {
	Get(key HttpRouteId) IRoute
	MustUrl(key HttpRouteId) string
	MustUrlElseDash(key HttpRouteId) string
	MustUrlRedirect(isLoggedIn bool) string
	MustUrlElseIsLogin(key HttpRouteId, isLoggedIn bool) string
	GetUrlNoLogin() string
	GetUrlInvalidPerms() string
	RouteExists(key HttpRouteId) bool
	LogError(c echo.Context, err error)
	LogAuthError(c echo.Context, err error)
	MatchesWhitelistActionPath(targetPath string) bool
}

IWebRouteController defines the interface for WebRouteManager in production context

type IWebRouteManager

type IWebRouteManager interface {
	GetAuthenticateProvisioner() amidware.IAuthenticateProvisioner
	SetAuthenticateProvisioner(provisioner amidware.IAuthenticateProvisioner)
	AddRoute(e *echo.Echo, route IRoute) error
	SetRouteSpecials(rHome HttpRouteId, rDash HttpRouteId, rNoLogin HttpRouteId, rInvalidPerms HttpRouteId) error
	InitRoutesWithEcho(e *echo.Echo) error
	LogError(c echo.Context, err error)
	LogAuthError(c echo.Context, err error)
}

IWebRouteManager defines the interface for managing web routes.

type NewPageData

type NewPageData func(activeURL string, title string, us asessions.ILoginSessionPerm, data interface{}) map[string]interface{}

type NewPageDataPaginate

type NewPageDataPaginate func(activeURL string, title string, us asessions.ILoginSessionPerm, paginate azb.IPaginate, data interface{}) map[string]interface{}

type PageSessionController

type PageSessionController struct {
	AppVersion         *aapp.AppVersion
	WebRouteController IWebRouteController
	MinExtension       string
	IsPrivateSite      bool
	PublicUrl          string
	Constants          map[string]string
	// contains filtered or unexported fields
}

func NewPageSessionController

func NewPageSessionController(appVersion *aapp.AppVersion, webRouteController IWebRouteController, minExt string, isPrivate bool, publicUrl string, constants map[string]string) *PageSessionController

func (*PageSessionController) GetAppVersion

func (psc *PageSessionController) GetAppVersion() *aapp.AppVersion

GetAppVersion returns the application version

func (*PageSessionController) GetConst

func (ps *PageSessionController) GetConst(target string) string

func (*PageSessionController) GetIsPrivateSite

func (psc *PageSessionController) GetIsPrivateSite() bool

GetIsPrivateSite indicates whether the site is private

func (*PageSessionController) GetMinExtension

func (psc *PageSessionController) GetMinExtension() string

GetMinExtension returns the minimum extension required

func (*PageSessionController) GetPublicNetUrl

func (psc *PageSessionController) GetPublicNetUrl() *anetwork.NetURL

GetPublicNetUrl returns the public NetURL of the site

func (*PageSessionController) GetPublicUrl

func (psc *PageSessionController) GetPublicUrl() string

GetPublicUrl returns the public URL of the site

func (*PageSessionController) HasPerm

HasPerm checks if the user session has a specific permission object.

func (*PageSessionController) HasPermB

func (ps *PageSessionController) HasPermB(us asessions.ILoginSessionPerm, keyBits string) bool

HasPermB checks if the user session has a specific permission represented as a key-bit string.

func (*PageSessionController) HasPermBV

func (ps *PageSessionController) HasPermBV(us asessions.ILoginSessionPerm, key string, bit int) bool

HasPermBV checks if the user session has a specific permission value for a given key using bit representation.

func (*PageSessionController) HasPermKeyValueConst

func (ps *PageSessionController) HasPermKeyValueConst(us asessions.ILoginSessionPerm, key string, value string) bool

HasPermKeyValueConst checks if the user session has a specific permission value for a given key using constants.

func (*PageSessionController) HasPermS

func (ps *PageSessionController) HasPermS(us asessions.ILoginSessionPerm, keyPermValue string) bool

HasPermS checks if the user session has a specific permission as a key-perm-value string.

func (*PageSessionController) HasPermSV

func (ps *PageSessionController) HasPermSV(us asessions.ILoginSessionPerm, key string, value string) bool

HasPermSV checks if the user session has a specific permission value for a given key.

func (*PageSessionController) HasPermSet

HasPermSet checks if the user session has any matching permission with the target PermSet.

func (*PageSessionController) IfActiveUrlThenValue

func (ps *PageSessionController) IfActiveUrlThenValue(activeUrl string, targetUrlKey HttpRouteId, value string) string

func (*PageSessionController) MustUrl

func (psc *PageSessionController) MustUrl(httpRouteId HttpRouteId) string

MustUrl returns the URL for the specified HttpRouteId or panics if not found

func (*PageSessionController) RouteExists

func (psc *PageSessionController) RouteExists(httpRouteId HttpRouteId) bool

RouteExists checks if a route exists for the given HttpRouteId

func (*PageSessionController) WRC

type PageStatusDefault

type PageStatusDefault struct {
	HTTPCode     int
	MessageTitle string
	Message      string
	RouteId      HttpRouteId
}

PageStatusDefault is a default struct to display status for web pages. This may be too limiting to your situation, especially for multi-language support.

func (*PageStatusDefault) StatusMessage

func (p *PageStatusDefault) StatusMessage() string

func (*PageStatusDefault) StatusTitle

func (p *PageStatusDefault) StatusTitle() string

type PaginateLimit

type PaginateLimit struct {
	Label     string `json:"label,omitempty"`     // Display label for the limit.
	Limit     int    `json:"limit,omitempty"`     // Numeric value of the limit.
	IsDefault bool   `json:"isDefault,omitempty"` // Indicates if this limit is the default selection.
}

PaginateLimit defines the structure for a single pagination limit.

type PaginateLimits

type PaginateLimits []*PaginateLimit

PaginateLimits is a slice of pointers to PaginateLimit.

func DefaultPaginateLimits

func DefaultPaginateLimits() PaginateLimits

DefaultPaginateLimits returns the default set of pagination limits.

func (PaginateLimits) GetLimitElseDefault

func (pls PaginateLimits) GetLimitElseDefault(target int) int

GetLimitElseDefault returns the specified target limit if it exists, otherwise returns the default limit.

func (PaginateLimits) HasLimit

func (pls PaginateLimits) HasLimit(target int) bool

HasLimit checks if the specified target limit exists within the limits.

type PaginateNav

type PaginateNav struct {
	azb.Paginate // Embedding azb.Paginate for pagination functionality.

	AddZClick bool   `json:"addZClick,omitempty"` // Flag to add a 'zclick' class.
	ZUrl      string `json:"zurl,omitempty"`      // URL for the Z click action.

	Label string `json:"label,omitempty"` // Label for the pagination navigation.

	ShowPerPage   int            `json:"showPerPage,omitempty"`   // Number of items to show per page.
	LimitsPerPage PaginateLimits `json:"limitsPerPage,omitempty"` // Limits for items per page.

	// Controls specifies the order of display for pagination controls.
	Controls azb.ZBTypes `json:"controls,omitempty"`

	// LinkRender defines which navigation links to render.
	LinkRender struct {
		NoStart bool `json:"noStart,omitempty"` // Do not render the start link.
		NoEnd   bool `json:"noEnd,omitempty"`   // Do not render the end link.
		NoPrev  bool `json:"noPrev,omitempty"`  // Do not render the previous link.
		NoNext  bool `json:"noNext,omitempty"`  // Do not render the next link (corrected json tag from noText to noNext).
	} `json:"linkRender,omitempty"`
}

PaginateNav struct defines the structure for pagination navigation.

func (*PaginateNav) GetZClick

func (pn *PaginateNav) GetZClick() string

GetZClick returns the 'zclick' class if AddZClick is true.

type RouteBase

type RouteBase struct {
	RouteId         HttpRouteId       // Unique identifier of the route.
	Method          HttpMethod        // HTTP method associated with the route.
	Path            string            // URL path of the route.
	Perms           asessions.PermSet // Permissions required to access the route.
	RouteNotFoundId HttpRouteId       // Identifier of the route to use when the current route is not found.

	Whitelist string // whitelist is needed when using actions or maintenance mode.
	// contains filtered or unexported fields
}

RouteBase provides a base implementation of the IRoute interface.

func (*RouteBase) GetIndexAdded

func (rb *RouteBase) GetIndexAdded() int

GetIndexAdded returns the position at which the route was added.

func (*RouteBase) GetMethod

func (rb *RouteBase) GetMethod() HttpMethod

GetMethod returns the route's HTTP method.

func (*RouteBase) GetPath

func (rb *RouteBase) GetPath() string

GetPath returns the route's URL path.

func (*RouteBase) GetPerms

func (rb *RouteBase) GetPerms() asessions.PermSet

GetPerms returns the permissions required to access the route.

func (*RouteBase) GetRouteId

func (rb *RouteBase) GetRouteId() HttpRouteId

GetRouteId returns the route's unique identifier.

func (*RouteBase) GetRouteNotFoundId

func (rb *RouteBase) GetRouteNotFoundId() HttpRouteId

GetRouteNotFoundId returns the identifier of the route to use when the current route is not found.

func (*RouteBase) GetWhitelist

func (rb *RouteBase) GetWhitelist() string

GetWhitelist returns the whitelisted path.

type SCSOptions

type SCSOptions struct {
	// Name specifies the name of the session cookie, ensuring uniqueness if multiple sessions are used.
	Name string `json:"name"`

	// Domain specifies the 'Domain' attribute on the session cookie, defaulting to the domain that issued the cookie.
	Domain string `json:"domain"`

	// HttpOnly sets the 'HttpOnly' attribute on the session cookie, defaulting to true.
	HttpOnly bool `json:"httpOnly"`

	// Path sets the 'Path' attribute on the session cookie, defaulting to "/" (root).
	Path string `json:"path"`

	// Persist indicates whether the session cookie should be retained after the browser is closed.
	Persist bool `json:"persist"`

	// SameSite controls the 'SameSite' attribute on the session cookie, with a default value of Lax.
	SameSite http.SameSite `json:"sameSite"`

	// Secure indicates whether the 'Secure' attribute on the session cookie is set (recommended for production).
	Secure bool `json:"secure"`

	// IdleTimeoutMinutes specifies the maximum session inactivity period before expiration, in minutes. Default is 1440.
	IdleTimeoutMinutes int `json:"idleTimeoutMinutes"`

	// LifetimeMinutes sets the session's absolute maximum duration, independent of activity. Default is 1440 minutes (24 hours).
	LifetimeMinutes int `json:"lifetimeMinutes"`

	// IsTokenRequired specifies whether a token is generated on LoadCheck for all requests.
	IsTokenRequired bool `json:"isTokenRequired"`
	// contains filtered or unexported fields
}

SCSOptions is a configuration struct for session cookies used with scs.SessionManager. It provides session management customization options and ensures secure and structured handling of cookies and sessions. Use in conjunction with the alexedwards/scs library. See: https://github.com/alexedwards/scs/blob/master/session.go The MIT License (MIT); Copyright (c) 2016 Alex Edwards

func (*SCSOptions) Initialize

func (ss *SCSOptions) Initialize(scsStore scs.Store, gobRegister []interface{}, addToGlobalSCS bool) (*scs.SessionManager, error)

Initialize configures a new scs.SessionManager based on SCSOptions settings and an scs.Store for session storage. Registers types with gob for encoding/decoding session data if needed. If addToGlobalSCS is true, then the scs.SessionManager is auto-added to scsInstance. Returns a configured session manager or an error if initialization fails.

type ServiceUrl

type ServiceUrl struct {
	ListenPort int    `json:"listenPort"` // Port on which the service listens, between 1 and 65535.
	PublicUrl  string `json:"publicUrl"`  // Public URL for the service.
	CertFile   string `json:"certFile"`   // Path to the TLS certificate file (required if using HTTPS).
	KeyFile    string `json:"keyFile"`    // Path to the TLS key file (required if using HTTPS).
	// contains filtered or unexported fields
}

ServiceUrl holds configuration details for a service, including its port, public URL, and TLS certificate information if applicable.

func (*ServiceUrl) GetCertFile

func (su *ServiceUrl) GetCertFile() string

GetCertFile returns the certificate file.

func (*ServiceUrl) GetIsTLS

func (su *ServiceUrl) GetIsTLS() bool

GetIsTLS indicates whether the service is using HTTPS (TLS).

func (*ServiceUrl) GetKeyFile

func (su *ServiceUrl) GetKeyFile() string

GetKeyFile returns the key file.

func (*ServiceUrl) GetPublicUrl

func (su *ServiceUrl) GetPublicUrl() *url.URL

GetPublicUrl returns the parsed public URL as a *url.URL type. It is assumed that Validate() has been called before this method, so 'u' should be non-nil after successful validation.

func (*ServiceUrl) SetRootDir

func (su *ServiceUrl) SetRootDir(dirRoot string) error

SetRootDir sets the root directory. If any certificate is a relative path, then the rootDir is applied, if valid.

func (*ServiceUrl) Validate

func (su *ServiceUrl) Validate() error

Validate checks the ServiceUrl configuration for errors, including: - Valid listen port within the range [1, 65535] - Properly formatted PublicUrl - TLS file requirements if using HTTPS. Returns an error if validation fails, or nil if successful.

type UIElemOption

type UIElemOption struct {
	Type      azb.ZBType `json:"type,omitempty"`      // The internal type of the option.
	Title     string     `json:"title,omitempty"`     // The display title of the option.
	IsDefault bool       `json:"isDefault,omitempty"` // Indicates if this option is the default selection.
}

UIElemOption represents an option within a UI element, such as a dropdown.

func (*UIElemOption) GetIsDefault

func (ui *UIElemOption) GetIsDefault() bool

GetIsDefault returns whether the UI option is the default selection.

func (*UIElemOption) GetTitle

func (ui *UIElemOption) GetTitle() string

GetTitle returns the display title of the UI option, defaulting to the capitalized type if not set.

func (*UIElemOption) GetType

func (ui *UIElemOption) GetType() azb.ZBType

GetType returns the internal type of the UI option.

func (*UIElemOption) GetValue

func (ui *UIElemOption) GetValue() string

GetValue returns the string representation of the option's type.

type UIElemOptions

type UIElemOptions []*UIElemOption

UIElemOptions is a slice of UIElemOption pointers.

func (UIElemOptions) FindByType

func (uis UIElemOptions) FindByType(target azb.ZBType) *UIElemOption

FindByType searches for and returns the UI option with the matching type.

func (UIElemOptions) FindByValue

func (uis UIElemOptions) FindByValue(target azb.ZBType) *UIElemOption

FindByValue is an alias for FindByType, as they perform the same function.

func (UIElemOptions) FindDefault

func (uis UIElemOptions) FindDefault() *UIElemOption

FindDefault searches for and returns the default UI option, if any.

func (UIElemOptions) HasByType

func (uis UIElemOptions) HasByType(target azb.ZBType) bool

HasByType checks if there is a UI option with the matching type.

func (UIElemOptions) ToHTML

func (uis UIElemOptions) ToHTML(currValue string) string

ToHTML generates an HTML string representing the options as HTML 'option' elements.

type WebRoute

type WebRoute struct {
	RouteBase
	// contains filtered or unexported fields
}

WebRoute is a struct that implements IRoute using an echo.HandlerFunc. It represents a web route with a handler and base routing information.

func NewWROptions

func NewWROptions(httpRouteId HttpRouteId, method HttpMethod, url string, permSet asessions.PermSet, permStr []string, createRouteHandler CreateRouteHandler, doAutoWhitelist bool, whitelist string) *WebRoute

NewWROptions creates a new WebRoute with specified options for permissions, handlers, and whitelisting.

func NewWRPermSet

func NewWRPermSet(httpRouteId HttpRouteId, method HttpMethod, url string, permSet asessions.PermSet, createRouteHandler CreateRouteHandler) *WebRoute

NewWRPermSet initializes a WebRoute with a permission set and route handler.

func NewWRPermSetAutoWL

func NewWRPermSetAutoWL(httpRouteId HttpRouteId, method HttpMethod, url string, permSet asessions.PermSet, createRouteHandler CreateRouteHandler) *WebRoute

NewWRPermSetAutoWL initializes a WebRoute with a permission set and automatic whitelisting.

func NewWRPermSetEH

func NewWRPermSetEH(httpRouteId HttpRouteId, method HttpMethod, url string, permSet asessions.PermSet, handler echo.HandlerFunc) *WebRoute

NewWRPermSetEH creates a new WebRoute with permission sets based on the specified handler.

func NewWRPermSetEHAutoWL

func NewWRPermSetEHAutoWL(httpRouteId HttpRouteId, method HttpMethod, url string, permSet asessions.PermSet, handler echo.HandlerFunc) *WebRoute

NewWRPermSetEHAutoWL creates a new WebRoute with permission sets and automatic whitelisting.

func NewWRPermSetEHWL

func NewWRPermSetEHWL(httpRouteId HttpRouteId, method HttpMethod, url string, permSet asessions.PermSet, handler echo.HandlerFunc, whitelist string) *WebRoute

NewWRPermSetEHWL creates a new WebRoute with permission sets and a specified whitelist.

func NewWRPermSetWL

func NewWRPermSetWL(httpRouteId HttpRouteId, method HttpMethod, url string, permSet asessions.PermSet, createRouteHandler CreateRouteHandler, whitelist string) *WebRoute

NewWRPermSetWL initializes a WebRoute with a permission set and a specific whitelist.

func NewWRPermStr

func NewWRPermStr(httpRouteId HttpRouteId, method HttpMethod, url string, permStr []string, createRouteHandler CreateRouteHandler) *WebRoute

NewWRPermStr initializes a WebRoute with string permissions and a route handler.

func NewWRPermStrAutoWL

func NewWRPermStrAutoWL(httpRouteId HttpRouteId, method HttpMethod, url string, permStr []string, createRouteHandler CreateRouteHandler) *WebRoute

NewWRPermStrAutoWL initializes a WebRoute with string permissions and automatic whitelisting.

func NewWRPermStrEH

func NewWRPermStrEH(httpRouteId HttpRouteId, method HttpMethod, url string, permStr []string, handler echo.HandlerFunc) *WebRoute

NewWRPermStrEH creates a new WebRoute with permissions defined by strings and a handler.

func NewWRPermStrEHAutoWL

func NewWRPermStrEHAutoWL(httpRouteId HttpRouteId, method HttpMethod, url string, permStr []string, handler echo.HandlerFunc) *WebRoute

NewWRPermStrEHAutoWL creates a new WebRoute with string permissions and automatic whitelisting.

func NewWRPermStrEHWL

func NewWRPermStrEHWL(httpRouteId HttpRouteId, method HttpMethod, url string, permStr []string, handler echo.HandlerFunc, whitelist string) *WebRoute

NewWRPermStrEHWL creates a new WebRoute with string permissions and a specified whitelist.

func NewWRPermStrWL

func NewWRPermStrWL(httpRouteId HttpRouteId, method HttpMethod, url string, permStr []string, createRouteHandler CreateRouteHandler, whitelist string) *WebRoute

NewWRPermStrWL initializes a WebRoute with string permissions and a specific whitelist.

func (*WebRoute) CreateHandler

func (wr *WebRoute) CreateHandler() echo.HandlerFunc

CreateHandler returns the handler function associated with the WebRoute. This function is part of the WebRoute's implementation of the IRoute interface.

type WebRouteManager

type WebRouteManager struct {
	HttpRouteMap // Embedding HttpRouteMap for route management.
	// contains filtered or unexported fields
}

WebRouteManager manages the routing for web requests.

func NewWebRouteManager

func NewWebRouteManager() *WebRouteManager

func (*WebRouteManager) AddRoute

func (wrm *WebRouteManager) AddRoute(route IRoute) error

AddRoute adds a new route to the manager's route map.

func (*WebRouteManager) AddWhitelistActionPath

func (wrm *WebRouteManager) AddWhitelistActionPath(target string)

AddWhitelistActionPath adds a path to the whitelist, applying a mutex lock.

func (*WebRouteManager) GetAuthenticateProvisioner

func (wrm *WebRouteManager) GetAuthenticateProvisioner() amidware.IAuthenticateProvisioner

GetAuthenticateProvisioner retrieves the provisioner for authentication.

func (*WebRouteManager) InitRoutesWithEcho

func (wrm *WebRouteManager) InitRoutesWithEcho(e *echo.Echo) error

InitRoutesWithEcho initializes routes with the Echo instance.

func (*WebRouteManager) LogAuthError

func (wrm *WebRouteManager) LogAuthError(c echo.Context, err error)

LogAuthError logs an authentication error.

func (*WebRouteManager) LogError

func (wrm *WebRouteManager) LogError(c echo.Context, err error)

LogError logs an error.

func (*WebRouteManager) MatchesWhitelistActionPath

func (wrm *WebRouteManager) MatchesWhitelistActionPath(targetPath string) bool

MatchesWhitelistActionPath checks if a given path matches any in the whitelist.

func (*WebRouteManager) SetAuthenticateProvisioner

func (wrm *WebRouteManager) SetAuthenticateProvisioner(provisioner amidware.IAuthenticateProvisioner)

SetAuthenticateProvisioner sets the provisioner for authentication.

Jump to

Keyboard shortcuts

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