server

package
v0.0.0-...-b5dad65 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware[T any](auth Auth, next apiutil.Endpoint[T]) apiutil.Endpoint[*T]

func NewPubblrRouter

func NewPubblrRouter(cfg PubblrRouterConfig, baseRouter chi.Router) (chi.Router, error)

func NewPubblrServer

func NewPubblrServer(config PubblrRouterConfig, baseRouter chi.Router) *http.Server

Types

type Auth

type Auth interface {
	GenerateToken(username string) (string, error)
	VerifyToken(token string) (string, error)
}

type CreateAccountRequest

type CreateAccountRequest struct {
	Password string                     `json:"password"`
	Actor    activitystreams.ActorIface `json:"actor"`
}

type CreateAccountResponse

type CreateAccountResponse struct {
	Actor activitystreams.ActorIface `json:"actor"`
	JWT   string                     `json:"jwt"`
}

type DB

type DB interface {
	CreateObject(obj activitystreams.ObjectIface, user string, baseIdUrl url.URL) (activitystreams.ObjectIface, error)
	CreateInboxItem(item activitystreams.ActivityIface, user string) (activitystreams.ActivityIface, error)
	CreateOutboxItem(act activitystreams.ActivityIface, user string, baseIdUrl url.URL) (activitystreams.ActivityIface, error)
	GetOutboxItem(user, id string) (activitystreams.ActivityIface, error)
	GetInboxPage(user string, page, pageSize int) ([]activitystreams.ActivityIface, error)
	GetInboxCount(user string) (int, error)
	GetInboxItem(user, id string) (activitystreams.ActivityIface, error)
	GetOutboxPage(user string, page, pageSize int) ([]activitystreams.ActivityIface, error)
	GetOutboxCount(user string) (int, error)
	GetObject(user, typ, id string) (activitystreams.ObjectIface, error)
	CreateUser(user activitystreams.ActorIface, username, password string, baseIdUrl url.URL) (activitystreams.ActorIface, error)
	GetUser(username string) (activitystreams.ActorIface, error)
	CheckPassword(username, password string) error
}

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Middleware

type Middleware func(http.Handler) http.Handler

func SetContentType

func SetContentType(contentType string) Middleware

type PubblrRouter

type PubblrRouter struct {
	chi.Router
	Database DB
	Logger   apiutil.Logger
	Auth     Auth
	// contains filtered or unexported fields
}

func (*PubblrRouter) Create

func (*PubblrRouter) Deliver

func (router *PubblrRouter) Deliver(activity activitystreams.ActivityIface)

func (*PubblrRouter) GetFollowers

func (*PubblrRouter) GetFollowersPage

func (router *PubblrRouter) GetFollowersPage(r *http.Request) (*activitystreams.CollectionPage, http.Header, apiutil.Status)

func (*PubblrRouter) GetFollowing

func (*PubblrRouter) GetFollowingPage

func (router *PubblrRouter) GetFollowingPage(r *http.Request) (*activitystreams.CollectionPage, http.Header, apiutil.Status)

func (*PubblrRouter) GetInbox

func (*PubblrRouter) GetInboxItem

func (*PubblrRouter) GetInboxPage

func (*PubblrRouter) GetLiked

func (*PubblrRouter) GetLikedPage

func (*PubblrRouter) GetObject

func (*PubblrRouter) GetOutbox

OUTBOX

func (*PubblrRouter) GetOutboxActivity

func (router *PubblrRouter) GetOutboxActivity(r *http.Request) (activitystreams.ObjectIface, http.Header, apiutil.Status)

func (*PubblrRouter) GetOutboxPage

func (*PubblrRouter) GetStream

func (*PubblrRouter) GetStreamFollowers

func (router *PubblrRouter) GetStreamFollowers(r *http.Request) (*activitystreams.Collection, http.Header, apiutil.Status)

func (*PubblrRouter) GetStreamFollowersPage

func (router *PubblrRouter) GetStreamFollowersPage(r *http.Request) (*activitystreams.CollectionPage, http.Header, apiutil.Status)

func (*PubblrRouter) GetStreamPage

func (*PubblrRouter) GetStreams

func (*PubblrRouter) GetUser

func (*PubblrRouter) Login

func (router *PubblrRouter) Login(r *http.Request) (string, http.Header, apiutil.Status)

func (*PubblrRouter) PostObject

func (*PubblrRouter) PostToInbox

func (*PubblrRouter) PostUser

type PubblrRouterConfig

type PubblrRouterConfig struct {
	MountPath string                        `json:"mountPath"`
	Database  database.PubblrDatabaseConfig `json:"database"`
	Logger    logging.PubblrLoggerConfig    `json:"logger"`
	Auth      auth.AuthConfig               `json:"auth"`
	Host      string                        `json:"host"`
	Port      int                           `json:"port"`
	PageSize  int                           `json:"pageSize"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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