http

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const APIKeyHeaderName = "X-API-Key"
View Source
const SessionCookieName = "heimdall_sessionToken"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthService

type AuthService interface {
	Login(ctx context.Context, username, password string) (auth.Token, error)
	Logout(ctx context.Context, session string) error
	IntrospectToken(ctx context.Context, token string) (auth.TokenInfo, error)
	ValidateAPIKey(ctx context.Context, key string) error
}

type ClientService

type ClientService interface {
	ListClients(ctx context.Context) ([]store.Client, error)
	GetClient(ctx context.Context, id uuid.UUID) (store.Client, error)
	CreateClient(ctx context.Context, client store.NewClient) (store.Client, error)
	UpdateClient(ctx context.Context, id uuid.UUID, patch store.ClientPatch) (store.Client, error)
	DeleteClient(ctx context.Context, id uuid.UUID) error

	ListClientAPIKeys(ctx context.Context, clientID uuid.UUID) ([]store.APIKey, error)
	GenerateAPIKey(ctx context.Context, newKey store.NewAPIKey) (string, error)
	DeleteClientAPIKey(ctx context.Context, clientID, keyID uuid.UUID) error
}

type Server

type Server struct {
	Logger level.Logger
	Router chi.Router

	// DisableAuth skips all configured auth checks on all routes. This setting
	// is intended to be used in setup mode to allow initial users and clients
	// to be created.
	DisableAuth bool

	UserService   UserService
	ClientService ClientService
	AuthService   AuthService
}

func NewServer

func NewServer() *Server

NewServer builds a new server object with the default middleware and router already configured. This is the typical way that `Server`s should be created to ensure they have everything needed to function.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

ListenAndServe spins up the server to listen on the provided address. The allowed addresses follow the same rules as `http.ListenAndServe`.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type UserService

type UserService interface {
	ListUsers(ctx context.Context) ([]store.User, error)
	GetUser(ctx context.Context, id uuid.UUID) (store.User, error)
	CreateUser(ctx context.Context, user store.NewUser) (store.User, error)
	UpdateUser(ctx context.Context, id uuid.UUID, patch store.UserPatch) (store.User, error)
	DeleteUser(ctx context.Context, id uuid.UUID) error
}

Jump to

Keyboard shortcuts

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