Documentation
¶
Index ¶
- Constants
- func Helmet(ctx Context, next Handler)
- func InitContext(w http.ResponseWriter, r *http.Request, next Handler)
- func Recover(ctx Context, next Handler)
- func RequestLogger(ctx Context, next Handler)
- type Authenticated
- type BaseModel
- type CacheOption
- type Compression
- type Config
- type Context
- type Controller
- type Controllers
- type Handler
- type History
- type Middleware
- type Model
- type PasskeyAlg
- type PasskeyCreationOptions
- type PasskeyPubKey
- type PasskeyPubKeyAuthenticatorSelection
- type PasskeyPubKeyCredParam
- type PasskeyPubKeyCredParamType
- type PasskeyPubKeyExcludeCredential
- type PasskeyPubKeyRp
- type PasskeyPubKeyUser
- type Renderer
- type Route
- type Server
- type Session
- type TlsConfig
Constants ¶
View Source
const ( HeaderContentType string = "Content-Type" HeaderCacheControl string = "Cache-Control" HeaderContentEncoding string = "Content-Encoding" HeaderAcceptEncoding string = "Accept-Encoding" )
View Source
const ( MimeTypeJson string = "application/json; charset=utf-8" MimeTypeHtml string = "text/html; charset=utf-8" )
View Source
const CacheOneYear = 24 * time.Hour * 365
View Source
const (
CookieSession = "s"
)
View Source
const HistoryKey = "history"
Variables ¶
This section is empty.
Functions ¶
func InitContext ¶
func InitContext(w http.ResponseWriter, r *http.Request, next Handler)
func RequestLogger ¶
Types ¶
type Authenticated ¶
type Authenticated struct {
// contains filtered or unexported fields
}
func NewAuthenticatedMiddleware ¶
func NewAuthenticatedMiddleware(sessionService session.Service) *Authenticated
func (*Authenticated) Middleware ¶
func (middleware *Authenticated) Middleware(ctx Context, next Handler)
type CacheOption ¶
type CacheOption byte
const ( NoCache CacheOption = 1 << iota MustRevalidate NoStore Private Public Immutable )
func (CacheOption) IsSet ¶
func (flags CacheOption) IsSet(option CacheOption) bool
type Compression ¶
type Compression struct {
Middleware
}
func CompressionMiddleware ¶
func CompressionMiddleware() *Compression
type Config ¶
type Config struct {
Host string `json:"host" env:"UNIOND_WEB_HOST" validate:"hostname|ip"`
Port int `json:"port" env:"UNIOND_WEB_PORT" validate:"gt=0,lte=65536"`
Tls TlsConfig `json:"tls"`
}
func DefaultConfig ¶
func DefaultConfig() Config
type Context ¶
type Context interface {
session.Session
WithSession(session.Session) Context
WithResponseWriter(http.ResponseWriter) Context
Version() string
PathValue(param string) string
QueryValue(param string) string
Redirect(path string)
RedirectBackOr(fallback string)
SignOut(redirect string)
Json(data any)
Html(html []byte)
HttpError(err error)
GetSessionCookie() (*common.Ulid, error)
CacheControl(maxAge time.Duration, options CacheOption)
SetCookie(*http.Cookie)
ServeFileFS(files fs.FS, name string)
RequestHeader() http.Header
ResponseHeader() http.Header
FormValues() url.Values
ParseForm() (common.M, error)
Method() string
Url() *url.URL
// contains filtered or unexported methods
}
func MustContext ¶
func NewContext ¶
type Controller ¶
type Controllers ¶
type History ¶
type History struct {
// contains filtered or unexported fields
}
func HistoryMiddleware ¶
func (*History) Middleware ¶
type Middleware ¶
func (Middleware) Name ¶
func (middleware Middleware) Name() string
type PasskeyAlg ¶
type PasskeyAlg int
const ( AlgEdDsa PasskeyAlg = -8 AlgEs256 PasskeyAlg = -7 AlgRs256 PasskeyAlg = -257 )
type PasskeyCreationOptions ¶
type PasskeyCreationOptions struct {
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions
PublicKey PasskeyPubKey `json:"publicKey"`
}
type PasskeyPubKey ¶
type PasskeyPubKey struct {
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#attestation
// one of: "none", "direct", "enterprise", "indirect"
Attestation *string `json:"attestation,omitempty"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#attestationformats
AttestationFormats *[]string `json:"attestationFormats,omitempty"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#authenticatorselection
AuthenticatorSelection *PasskeyPubKeyAuthenticatorSelection `json:"authenticatorSelection,omitempty"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#challenge
// base64url encoding of an underlying []byte
Challenge string `json:"challenge"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#excludecredentials
ExcludeCredentials *[]PasskeyPubKeyExcludeCredential `json:"excludeCredentials,omitempty"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#extensions
// TODO: https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/WebAuthn_extensions
Extensions *any `json:"extensions,omitempty"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#hints
// one of: "security-key", "client-device", "hybrid"
Hints *[]string `json:"hints,omitempty"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#pubkeycredparams
PubKeyCredParams []PasskeyPubKeyCredParam `json:"pubKeyCredParams"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#rp
Rp PasskeyPubKeyRp `json:"rp"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#timeout
Timeout *uint `json:"timeout,omitempty"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#user
User PasskeyPubKeyUser `json:"user"`
}
type PasskeyPubKeyAuthenticatorSelection ¶
type PasskeyPubKeyAuthenticatorSelection struct {
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#authenticatorattachment
// one of: "platform", "cross-platform"
AuthenticatorAttachment *string `json:"authenticatorAttachment,omitempty"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#requireresidentkey
RequireResidentKey *bool `json:"requireResidentKey,omitempty"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#residentkey
// one of: "discouraged", "preferred", "required"
ResidentKey *string `json:"residentKey,omitempty"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#userverification
// one of: "discouraged", "preferred", "required"
UserVerification *string `json:"userVerification,omitempty"`
}
type PasskeyPubKeyCredParam ¶
type PasskeyPubKeyCredParam struct {
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#alg
Alg PasskeyAlg `json:"alg"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#type_2
Type PasskeyPubKeyCredParamType `json:"type"`
}
type PasskeyPubKeyCredParamType ¶
type PasskeyPubKeyCredParamType string
const (
PasskeyPubKeyType PasskeyPubKeyCredParamType = "public-key"
)
type PasskeyPubKeyExcludeCredential ¶
type PasskeyPubKeyExcludeCredential struct {
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#id
Id string `json:"id"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#transports
// one of: "ble", "hybrid", "internal", "nfc", "usb"
Transports *[]string `json:"transports,omitempty"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#type
// literal: "public-key"
Type PasskeyPubKeyCredParamType `json:"type"`
}
type PasskeyPubKeyRp ¶
type PasskeyPubKeyRp struct {
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#id_2
Id *string `json:"id,omitempty"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#name
Name string `json:"name"`
}
type PasskeyPubKeyUser ¶
type PasskeyPubKeyUser struct {
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#displayname
DisplayName string `json:"displayName"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#id_3
Id string `json:"id"`
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredentialCreationOptions#name_2
Name string `json:"name"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer( name string, conf *Config, controller Controllers, globalMiddleware []Middleware, ) (*Server, common.Closer, error)
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func SessionMiddleware ¶
func SessionMiddleware( sessionService session.Service, localsService locals.MemberService, ) *Session
func (*Session) Middleware ¶
Click to show internal directories.
Click to hide internal directories.