httpserver

package
v0.0.0-...-175e951 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractIP

func ExtractIP(req *http.Request) string

func ExtractIPDirect

func ExtractIPDirect(req *http.Request) string

func ExtractIPXFF

func ExtractIPXFF(req *http.Request) string

func GetBaseURL

func GetBaseURL(c context.Context) *url.URL

func GetRequest

func GetRequest(c context.Context) *http.Request

func GetResponseWriter

func GetResponseWriter(c context.Context) http.ResponseWriter

func GracefulServe

func GracefulServe(srv *http.Server, shutdownTimeout time.Duration) error

func IsHttps

func IsHttps(c context.Context) bool

func IsSecure

func IsSecure(r *http.Request) bool

func LoggerMiddleware

func LoggerMiddleware(next http.Handler) http.Handler

func MakeServer

func MakeServer(
	conf *HttpServerConfigDef,
	dbConf *db.DBConfigDef,
	storageConf *storage.StorageConfigDef,
	emailConf *email.EmailConfigDef,
	cleanupConf *storage.CleanupConfig,
) *http.Server

func NewGqlResolver

func NewGqlResolver(
	identityManager *IdentityManager,
	storageDefRepo storage.StorageDefRepo,
	imageRepo image.ImageRepo,
	imageDomain string,
	defaultURLFormat domainmodels.ImageURLFormat,
	getEmailBackend func(c context.Context) email.EmailBackend,
	secretKey string,
	captchaClient captcha.CaptchaClient,
	allowNewUser bool,
) *graph.Resolver

func NewGraphConfig

func NewGraphConfig(resolver *graph.Resolver) graph.Config

func RWContextMiddleware

func RWContextMiddleware(next http.Handler) http.Handler

Types

type ContextKey

type ContextKey string

type HttpContextUserManager

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

func NewContextUserManager

func NewContextUserManager(contextKey string, identityRepo identity.IdentityRepo) *HttpContextUserManager

func (*HttpContextUserManager) GetAuthenticationInfo

func (cu *HttpContextUserManager) GetAuthenticationInfo(c context.Context) *identity.AuthenticationInfo

func (*HttpContextUserManager) SetAuthenticationInfo

func (cu *HttpContextUserManager) SetAuthenticationInfo(c context.Context, authenticationInfo *identity.AuthenticationInfo)

func (*HttpContextUserManager) WithAuthenticationInfo

func (cu *HttpContextUserManager) WithAuthenticationInfo(c context.Context, authenticationInfo *identity.AuthenticationInfo) context.Context

type HttpServerConfigDef

type HttpServerConfigDef struct {
	Bind                   string
	WriteTimeout           int
	ReadTimeout            int
	TemplatesFS            fs.FS
	StaticFS               fs.FS
	SessionKey             string
	RedisURIForSession     string
	RedisURI               string
	SiteName               string
	SiteTitle              string
	ImageDomain            string
	DefaultURLFormat       domainmodels.ImageURLFormat
	EnableGqlPlayground    bool
	EnableSafeImageCheck   bool
	SafeImageCheckEndpoint string
	CaptchaProvider        captcha.CaptchaProvider
	RecaptchaClientKey     string
	TurnstileSiteKey       string
	RecaptchaServerKey     string
	TurnstileSecretKey     string
	CustomCSS              string
	CustomJS               string
	AllowUpload            bool
	AllowNewUser           bool
}

func ReadServerConfigFromEnv

func ReadServerConfigFromEnv() HttpServerConfigDef

type IdentityManager

type IdentityManager struct {
	IdentityRepo       identity.IdentityRepo
	ContextUserManager identity.ContextUserManager
	Persister          persister.Persister
}

func NewIdentityManager

func NewIdentityManager(identityRepo identity.IdentityRepo, persister persister.Persister) *IdentityManager

func (*IdentityManager) Authenticate

func (i *IdentityManager) Authenticate(w http.ResponseWriter, r *http.Request, userId string, organizationUserId string)

func (*IdentityManager) AuthenticateContext

func (i *IdentityManager) AuthenticateContext(c context.Context, userId string, organzationUserId string)

func (*IdentityManager) Logout

func (i *IdentityManager) Logout(w http.ResponseWriter, r *http.Request)

func (*IdentityManager) LogoutContext

func (i *IdentityManager) LogoutContext(c context.Context)

func (*IdentityManager) Middleware

func (i *IdentityManager) Middleware(next http.Handler) http.Handler

type UploadReturn

type UploadReturn struct {
	Filename   string `json:"filename"`
	URL        string `json:"url"`
	Identifier string `json:"identifier"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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