router

package
v0.0.0-...-2b12306 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ResponseCodeToErrorCode = map[int]ErrorCode{
		http.StatusInternalServerError: ErrorCodeInternal,
	}
)

Functions

func AuthenticateMiddleware

func AuthenticateMiddleware(authenticator authn.Authenticator) echo.MiddlewareFunc

func GenerateRequestID

func GenerateRequestID() string

func GetAuthResult

func GetAuthResult(c echo.Context) *authn.Result

func GetRequestID

func GetRequestID(c echo.Context) string

func HTTPErrorHandler

func HTTPErrorHandler(logger *slog.Logger) echo.HTTPErrorHandler

func LoggingMiddleware

func LoggingMiddleware(logger *slog.Logger) echo.MiddlewareFunc

func RequestIDMiddleware

func RequestIDMiddleware() echo.MiddlewareFunc

Types

type Error

type Error struct {
	Message   string    `json:"message"`
	ErrorCode ErrorCode `json:"error_code"`
	Err       error     `json:",omitempty"`
}

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode string
const (
	ErrorCodeInternal ErrorCode = "internal_error"
)

type Handler

type Handler struct {
	Logger *slog.Logger
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(client *gh.Client, authenticator authn.Authenticator, logger *slog.Logger) *Handler

func (*Handler) HandleAuth

func (h *Handler) HandleAuth(ctx echo.Context) error

func (*Handler) Start

func (h *Handler) Start() error

type InternalError

type InternalError struct {
	Err error
}

func InternalServerError

func InternalServerError(err error) *InternalError

func (*InternalError) Error

func (e *InternalError) Error() string

func (*InternalError) Unwrap

func (e *InternalError) Unwrap() error

type Request

type Request struct {
	RemoteIP  string `json:"remote_ip"`
	Method    string `json:"method"`
	URL       string `json:"url"`
	Host      string `json:"host"`
	Status    int    `json:"status"`
	UserAgent string `json:"user_agent"`
	RequestID string `json:"request_id"`
	LatencyMs int    `json:"latency_ms"`
}

func (*Request) LogValue

func (r *Request) LogValue() slog.Value

Jump to

Keyboard shortcuts

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