http

package
v0.0.0-...-4f898de Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authentication

func Authentication(userStore docshelf.UserStore) func(http.Handler) http.Handler

Authentication is a middleware that verifies a user's identity before passing control to the underlying HTTP handler. If the user is verified, their data is pulled and attached to the request context so it can be referenced at all stages later on.

Types

type Auth

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

Auth provides a simple implementation of the Authenticator interface. It does a simple lookup of the user and confirms whether or not the credentials match what's stored.

func NewAuth

func NewAuth(userStore docshelf.UserStore) Auth

NewAuth returns a new instance of Auth configured with the given docshelf.UserStore.

func (Auth) Authenticate

func (a Auth) Authenticate(ctx context.Context, email, token string) (docshelf.User, error)

Authenticate implements the docshelf.Authenticator interface. It does a simple pull of the user from a UserStore and compares the attempted token with the stored hashed token.

type Claims

type Claims struct {
	jwt.StandardClaims

	Email string `json:"email"`
	Name  string `json:"name"`
}

Claims represent claimed data embedded in an ouath access token.

type DocHandler

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

A DocHandler has methods that can handle HTTP requests for Docs.

func NewDocHandler

func NewDocHandler(docStore docshelf.DocStore, logger *logrus.Logger) DocHandler

NewDocHandler returns a DocHandler struct using the given DocStore and Logger instance.

func (DocHandler) DeleteDoc

func (h DocHandler) DeleteDoc(w http.ResponseWriter, r *http.Request)

DeleteDoc handles requests for removing specific Docs.

func (DocHandler) GetDoc

func (h DocHandler) GetDoc(w http.ResponseWriter, r *http.Request)

GetDoc handles requests for fetching specific Docs.

func (DocHandler) GetList

func (h DocHandler) GetList(w http.ResponseWriter, r *http.Request)

GetList handles requests for listing Docs by path prefix.

func (DocHandler) PinDoc

func (h DocHandler) PinDoc(w http.ResponseWriter, r *http.Request)

PinDoc handles requests from users to pin a document. It applies a special tag to the doc which can be used later to find a user's pinned documents.

func (DocHandler) PostDoc

func (h DocHandler) PostDoc(w http.ResponseWriter, r *http.Request)

PostDoc handles requests for posting new (or existing) Docs.

func (DocHandler) PostTag

func (h DocHandler) PostTag(w http.ResponseWriter, r *http.Request)

PostTag handles requests for posting tags to an existing Doc.

func (DocHandler) RenderDoc

func (h DocHandler) RenderDoc(w http.ResponseWriter, r *http.Request)

RenderDoc handles requests for rendering Documents as HTML.

type ID

type ID struct {
	ID string `json:"id"`
}

ID is a struct for marshaling to and from JSON documents containing an ID.

type Server

type Server struct {
	DocHandler  DocHandler
	UserStore   docshelf.UserStore
	GroupStore  docshelf.GroupStore
	PolicyStore docshelf.PolicyStore
	// contains filtered or unexported fields
}

A Server is a collection of stores that get wired up to HTTP endpoint.

func NewServer

func NewServer(host string, port uint, logger *logrus.Logger) Server

NewServer returns a new Server struct.

func (Server) AddAuth

func (s Server) AddAuth(name string, auth docshelf.Authenticator)

AddAuth method to server.

func (Server) CheckHandlers

func (s Server) CheckHandlers() error

CheckHandlers returns an error if the Server contains any invalid handlers.

func (Server) Start

func (s Server) Start() error

Start fires up an HTTP server and listens for incoming requests.

type TagReq

type TagReq struct {
	Path string
	Tags []string
}

A TagReq is a request to apply tags to a given document.

type UserHandler

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

A UserHandler has methods that can handle HTTP requests for Users.

func NewUserHandler

func NewUserHandler(userStore docshelf.UserStore, logger *logrus.Logger) UserHandler

NewUserHandler returns a UserHandler struct using the given UserStore and Logger instance.

func (UserHandler) DeleteUser

func (h UserHandler) DeleteUser(w http.ResponseWriter, r *http.Request)

DeleteUser handles requests for deleting specific Users.

func (UserHandler) GetCurrentUser

func (h UserHandler) GetCurrentUser(w http.ResponseWriter, r *http.Request)

GetCurrentUser handles requests for fetching the currently logged in user.

func (UserHandler) GetUser

func (h UserHandler) GetUser(w http.ResponseWriter, r *http.Request)

GetUser handles requests for fetching specific Users.

func (UserHandler) GetUsers

func (h UserHandler) GetUsers(w http.ResponseWriter, r *http.Request)

GetUsers handles requests for listing all Users.

func (UserHandler) PostUser

func (h UserHandler) PostUser(w http.ResponseWriter, r *http.Request)

PostUser handles requests for posting new (or updating existing) Users.

Jump to

Keyboard shortcuts

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