handlers

package
v0.0.0-...-876d392 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachAcronym

func AttachAcronym(r *mux.Router)

AttachAcronym is to add api paths related to acronyms

func AttachDir

func AttachDir(r *mux.Router)

AttachDir is for connecting folder related api paths

func AttachFile

func AttachFile(r *mux.Router)

AttachFile is to add file api paths

func AttachGroup

func AttachGroup(r *mux.Router)

AttachGroup adds api paths related to group actions

func AttachNLP

func AttachNLP(r *mux.Router)

AttachNLP adds route to router for getting nlp data generated by the processing system

func AttachOwner

func AttachOwner(r *mux.Router)

AttachOwner adds api paths related to owner actions

func AttachPerm

func AttachPerm(r *mux.Router)

AttachPerm is for paths related to permission actions

func AttachPublic

func AttachPublic(r *mux.Router)

AttachPublic is for searching public available files

func AttachRecord

func AttachRecord(r *mux.Router)

AttachRecord adds paths for basic file actions TODO: combine with AttachFile

func AttachSearch

func AttachSearch(r *mux.Router)

AttachSearch adds handlers for searching the tags of files

func AttachUser

func AttachUser(r *mux.Router)

AttachUser hooks up paths for handling user related requests

func ConnectDatabase

func ConnectDatabase(next http.Handler) http.Handler

ConnectDatabase is a middleware the opens a connection to the database and populates the request context with connection objects

func Logging

func Logging(next http.Handler) http.Handler

Logging is a middleware to log requests and responses

func ParseBody

func ParseBody(next http.Handler) http.Handler

ParseBody parses request's body allows for requests to be formed as json or normal request forms

func Recovery

func Recovery(next http.Handler) http.Handler

Recovery is a middleware to recover from panics in handling requests

func Timeout

func Timeout(next http.Handler) http.Handler

Timeout puts a timeout on request length

func UserCookie

func UserCookie(next http.Handler) http.Handler

UserCookie Token verification MiddleWare

Types

type CompletePackage

type CompletePackage struct {
	User    userProfile             `json:"user"`
	Public  publicProfile           `json:"public"`
	Groups  map[string]groupProfile `json:"groups"`
	Records map[string]fileProfile  `json:"files"`
}

CompletePackage is a full set of metadata relating to a particular user

type ContextKey

type ContextKey byte

ContextKey type used to map in values into request context

const (
	// USER is for the currect user
	USER ContextKey = iota
	// GROUP is for the group the handler is meant to operate on or with
	GROUP
)

type DirInformation

type DirInformation struct {
	Name  string         `json:"name"`
	Files []types.FileID `json:"files"`
}

DirInformation is the json encoding for folder information

type FileContent

type FileContent struct {
	Length int                 `json:"size"`
	Vals   []types.ContentLine `json:"lines"`
}

FileContent is the json encoding for lines from a file

type FileInfo

type FileInfo struct {
	File  types.FileI `json:"file"`
	Count int64       `json:"count,omitempty"` //sentence count
	Size  int64       `json:"size,omitempty"`  //size of original file in bytes
}

FileInfo json response type of file information

type GroupInformation

type GroupInformation struct {
	ID      string   `json:"id"`
	Name    string   `json:"name"`
	Owner   string   `json:"owner"`
	Members []string `json:"members,omitempty"`
}

GroupInformation is the json encoding object for Groups

func BuildGroupInfo

func BuildGroupInfo(grp types.GroupI) GroupInformation

BuildGroupInfo contructs Group Response Object from Group

type ResWrtrCapturer

type ResWrtrCapturer struct {
	StatusCode int
	// contains filtered or unexported fields
}

ResWrtrCapturer http.ResponseWriter that saves status code

func (*ResWrtrCapturer) Header

func (rwc *ResWrtrCapturer) Header() http.Header

Header implements http.ResponseWriter

func (*ResWrtrCapturer) Write

func (rwc *ResWrtrCapturer) Write(b []byte) (int, error)

Write implements http.ResponseWriter

func (*ResWrtrCapturer) WriteHeader

func (rwc *ResWrtrCapturer) WriteHeader(sc int)

WriteHeader implements http.ResponseWriter

type SearchResponse

type SearchResponse struct {
	Files []FileInfo `json:"matched"`
}

SearchResponse json response of matched files to a search

func BuildSearchResponse

func BuildSearchResponse(r *http.Request, fids []types.FileID) SearchResponse

BuildSearchResponse contructs SearchResponse from a list of matched fileids

type UserInfo

type UserInfo struct {
	ID    string   `json:"id"`
	Name  string   `json:"name"`
	Roles []string `json:"roles,omitempty"`
	Data  struct {
		Current int64 `json:"current"`
		Total   int64 `json:"total"`
	} `json:"data,omitempty"`
}

UserInfo is the json contruction struct for user information

func BuildUserInfo

func BuildUserInfo(r *http.Request, u types.UserI) UserInfo

BuildUserInfo builds user info from user object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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