types

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

README

types

Общие типы и callback-контракты для компонентов Sudzekai Web OS.

Установка

go get github.com/sudzekai-web-os/types

Результаты

HandlerResult описывает результат HTTP-обработчика:

types.HandlerResult{
	Data:       response,
	StatusCode: http.StatusOK,
}

CommandResult содержит Stdout, Stderr и Error после выполнения внешней команды.

HTTP-контракты

  • HandlerFunc — функция func(*http.Request) HandlerResult.
  • Middleware — стандартное HTTP middleware.
  • ResultFilter — функция формирования ответа из HandlerResult.
  • JwtMiddleware — адаптер защиты обработчика с учетом списка ролей.
  • ProtectedHandlerFunc — обработчик и разрешенные роли; создается через NewProtectedHandler.

Уровни логирования

LogLevel содержит уровни Debug, Information, Warning, Error и Critical. Значение None используется для отсутствия уровня. Метод String возвращает текстовое представление уровня.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandResult

type CommandResult struct {
	Stdout string
	Stderr string
	Error  error
}

type HandlerFunc

type HandlerFunc func(r *http.Request) (result HandlerResult)

type HandlerResult

type HandlerResult struct {
	Data       any
	Error      error
	StatusCode int
}

type JwtMiddleware

type JwtMiddleware func(HandlerFunc, []string) HandlerFunc

type LogLevel

type LogLevel int
const (
	None  LogLevel = -1
	Debug LogLevel = iota
	Information
	Warning
	Error
	Critical
)

func (LogLevel) String

func (l LogLevel) String() string

type Middleware

type Middleware func(http.Handler) http.Handler

type ProtectedHandlerFunc

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

func NewProtectedHandler

func NewProtectedHandler(hnd HandlerFunc, roles []string) ProtectedHandlerFunc

func (*ProtectedHandlerFunc) GetHandler

func (ph *ProtectedHandlerFunc) GetHandler() HandlerFunc

func (*ProtectedHandlerFunc) GetRoles

func (ph *ProtectedHandlerFunc) GetRoles() []string

type ResultFilter

type ResultFilter func(w http.ResponseWriter, r *http.Request, result HandlerResult)

Jump to

Keyboard shortcuts

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