MSP-8974 review fixes

This commit is contained in:
chashintv committed 2026-11-23 13:00:03 +03:00
1 parent 1ea3ef186c
commit 7bac2e403f
20 files changed
+189 -466

No files matched your search

-80
View File
@@ -7,86 +7,6 @@ import (
"github.com/txix-open/isp-kit/errors"
)
const (
// ApplicationIdHeader is the header key for application identity.
ApplicationIdHeader = "x-application-identity"
// ApplicationNameHeader is the header key for application name.
ApplicationNameHeader = "x-application-name"
// UserIdHeader is the header key for user identity.
UserIdHeader = "x-user-identity"
// DeviceIdHeader is the header key for device identity.
DeviceIdHeader = "x-device-identity"
// ServiceIdHeader is the header key for service identity.
ServiceIdHeader = "x-service-identity"
// DomainIdHeader is the header key for domain identity.
DomainIdHeader = "x-domain-identity"
// SystemIdHeader is the header key for system identity.
SystemIdHeader = "x-system-identity"
// UserTokenHeader is the header key for user token.
UserTokenHeader = "x-user-token"
// DeviceTokenHeader is the header key for device token.
DeviceTokenHeader = "x-device-token"
)
// AuthData wraps http.Header to provide structured access to authentication
// and authorization information from http request header.
// All methods return an error if the key is not found or cannot be parsed.
type AuthData http.Header
// SystemId extracts the system identity from header as an integer.
// Returns an error if the key is not found or the value cannot be parsed as an integer.
func (i AuthData) SystemId() (int, error) {
return IntFromHeader(SystemIdHeader, http.Header(i))
}
// DomainId extracts the domain identity from header as an integer.
// Returns an error if the key is not found or the value cannot be parsed as an integer.
func (i AuthData) DomainId() (int, error) {
return IntFromHeader(DomainIdHeader, http.Header(i))
}
// ServiceId extracts the service identity from header as an integer.
// Returns an error if the key is not found or the value cannot be parsed as an integer.
func (i AuthData) ServiceId() (int, error) {
return IntFromHeader(ServiceIdHeader, http.Header(i))
}
// ApplicationId extracts the application identity from header as an integer.
// Returns an error if the key is not found or the value cannot be parsed as an integer.
func (i AuthData) ApplicationId() (int, error) {
return IntFromHeader(ApplicationIdHeader, http.Header(i))
}
// ApplicationName extracts the application name from header as a string.
// Returns an error if the key is not found.
func (i AuthData) ApplicationName() (string, error) {
return StringFromHeader(ApplicationNameHeader, http.Header(i))
}
// UserId extracts the user identity from header as an integer.
// Returns an error if the key is not found or the value cannot be parsed as an integer.
func (i AuthData) UserId() (int, error) {
return IntFromHeader(UserIdHeader, http.Header(i))
}
// DeviceId extracts the device identity from header as an integer.
// Returns an error if the key is not found or the value cannot be parsed as an integer.
func (i AuthData) DeviceId() (int, error) {
return IntFromHeader(DeviceIdHeader, http.Header(i))
}
// UserToken extracts the user token from header as a string.
// Returns an error if the key is not found.
func (i AuthData) UserToken() (string, error) {
return StringFromHeader(UserTokenHeader, http.Header(i))
}
// DeviceToken extracts the device token from header as a string.
// Returns an error if the key is not found.
func (i AuthData) DeviceToken() (string, error) {
return StringFromHeader(DeviceTokenHeader, http.Header(i))
}
// StringFromHeader extracts a string value from header by key.
// Returns an error if header is nil or the key is not found.
func StringFromHeader(key string, h http.Header) (string, error) {