http

package
v0.0.0-...-4efd307 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 66 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiKeyHeaderKey        = "x-api-key"
	AuthorizationHeaderKey = "authorization"
)
View Source
const ValidationErrorSeparator = "$$$$"

Variables

This section is empty.

Functions

func GinContextFromCtx

func GinContextFromCtx(ctx context.Context) (*gin.Context, error)

GinContext returns the gin context from the request context.

func GinContextToContextMiddleware

func GinContextToContextMiddleware() gin.HandlerFunc

func LogResponseMiddleware

func LogResponseMiddleware(out io.Writer) gin.HandlerFunc

func NewAuthMiddleware

func NewAuthMiddleware(
	logger *zap.SugaredLogger,
	authn *auth.Authentication,
	client *generated.Client,
) *authMiddleware

func Open

func Open(databaseUrl string) *generated.Client

Open new connection.

func Run

func Run(env string) (<-chan error, error)

Run configures a server and underlying services with the given configuration. NewServer takes its own config as is now.

Types

type AuthState

type AuthState struct {
	Nonce       string          `json:"nonce"`
	LoginMode   OAuth2LoginMode `json:"login_mode"`
	RedirectURI string          `json:"redirect_uri"`
	Signature   string          `json:"signature"`
}

type Config

type Config struct {
	// Port to listen to. Use ":0" for a random port.
	Address string
	Pool    *pgxpool.Pool
	SQLPool *sql.DB
	Logger  *zap.SugaredLogger
}

type Handlers

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

func (*Handlers) SignOut

func (h *Handlers) SignOut(c *gin.Context)

type OAuth2LoginMode

type OAuth2LoginMode string
const (
	OAuth2LoginModeUser        OAuth2LoginMode = "user"
	OAuth2LoginModeBroadcaster OAuth2LoginMode = "broadcaster"
)

func (OAuth2LoginMode) Valid

func (l OAuth2LoginMode) Valid() bool

type OAuth2Provider

type OAuth2Provider interface {
	rp.RelyingParty
}

type OAuth2Providers

type OAuth2Providers map[OAuth2LoginMode]OAuth2Provider

type Server

type Server struct {
	Httpsrv *http.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, conf Config, opts ...ServerOption) (*Server, error)

NewServer returns a new http server.

type ServerOption

type ServerOption func(*Server)

func WithMiddlewares

func WithMiddlewares(mws ...gin.HandlerFunc) ServerOption

WithMiddlewares adds the given middlewares before registering the main routers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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