server

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const MentionStatusApproved = "approved"
View Source
const MentionStatusInvalid = "invalid"
View Source
const MentionStatusNew = "new"
View Source
const MentionStatusRejected = "rejected"
View Source
const MentionStatusVerified = "verified"

Variables

This section is empty.

Functions

func AuthorizeContext

func AuthorizeContext(ctx context.Context) context.Context

AuthorizeContext marks the current context as being authorized.

Types

type AuthConfiguration

type AuthConfiguration struct {
	AdminEmails         []string
	AdminAccessKeys     map[string]string
	AdminAccessKeyJWTTL time.Duration
	JWTSecret           string
	JWTTTL              time.Duration
	StaticAccessKeys    []StaticAccessKey
}

type Claims added in v1.1.0

type Claims struct {
	jwt.RegisteredClaims
}

type Configuration

type Configuration struct {
	Context                     context.Context
	Database                    *sql.DB
	MigrationsFolder            string
	Receiver                    ReceiverConfiguration
	Sender                      SenderConfiguration
	Auth                        AuthConfiguration
	MailFrom                    string
	Mailer                      mailer.Mailer
	AllowedOrigins              []string
	PublicURL                   string
	UIPath                      string
	VerificationTimeoutDuration time.Duration
	VerificationMaxRedirects    int
	NotifyOnVerification        bool
	Policies                    *policies.Registry
	PolicyLoader                policies.Loader
	ExposeMetrics               bool
}

type Configurator

type Configurator func(c *Configuration)

type HTTPError

type HTTPError struct {
	StatusCode int
	Err        error
	Message    string
}

HTTPError is a simple error wrapper that adds a HTTP status code.

func (*HTTPError) Error

func (e *HTTPError) Error() string

func (*HTTPError) Unwrap

func (e *HTTPError) Unwrap() error

type Mention

type Mention struct {
	ID         string `json:"id"`
	Source     string `json:"source"`
	Target     string `json:"target"`
	CreatedAt  string `json:"created_at"`
	Status     string `json:"status,omitempty"`
	Title      string `json:"title,omitempty"`
	Content    string `json:"content,omitempty"`
	AuthorName string `json:"author_name,omitempty"`
	Type       string `json:"type,omitempty"`
	RSVP       string `json:"rsvp,omitempty"`
}

type PagedMentionList

type PagedMentionList struct {
	Items []Mention `json:"items"`
	Total int       `json:"total"`
	Next  string    `json:"next,omitempty"`
}

type ReceiverConfiguration

type ReceiverConfiguration struct {
	TargetPolicy RequestPolicy
}

type RequestPolicy

type RequestPolicy func(*http.Request) bool

RequestPolicy functions allow you to mark incoming requests as allowed or denied.

func RequestPolicyAllowHost

func RequestPolicyAllowHost(hosts ...string) RequestPolicy

RequestPolicyAllowHost creates a policy that allows only requests targeted at specific hosts.

type SendRequest

type SendRequest struct {
	Source string `json:"source"`
}

type SendResponse

type SendResponse struct {
	Source  string                     `json:"source"`
	Targets []SendResponseTargetStatus `json:"targets"`
}

type SendResponseTargetStatus

type SendResponseTargetStatus struct {
	URL      string `json:"url"`
	Endpoint string `json:"endpoint"`
	Error    string `json:"error"`
}

type SenderConfiguration

type SenderConfiguration struct{}

type Server

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

Server implements the http.Handler interface and deals with inserting new webmentions into the database.

func New

func New(configurators ...Configurator) *Server

func (*Server) MigrateDatabase

func (srv *Server) MigrateDatabase(ctx context.Context) error

MigrateDatabase tries to update the underlying database to the latest version.

func (*Server) ServeHTTP

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

func (*Server) StartVerifier

func (srv *Server) StartVerifier(ctx context.Context)

func (*Server) UpdateGlobalMetrics

func (srv *Server) UpdateGlobalMetrics(ctx context.Context) error

func (*Server) VerifyNextMention

func (srv *Server) VerifyNextMention(ctx context.Context) (bool, error)

VerifyNextMention tries to take the next pending mention from the database and tries to verify it.

type StaticAccessKey added in v1.1.0

type StaticAccessKey struct {
	Key  string
	Name string
}

Jump to

Keyboard shortcuts

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