rest

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUserInfo

func GetUserInfo(r *http.Request) (user store.User, err error)

GetUserInfo returns user from request context

func MustGetUserInfo

func MustGetUserInfo(r *http.Request) store.User

MustGetUserInfo fails if can't extract user data from the request. should be called from authed controllers only

func SendErrorJSON

func SendErrorJSON(w http.ResponseWriter, r *http.Request, code int, err error, details string)

SendErrorJSON makes {error: blah, details: blah} json body and responds with error code

func SetUserInfo

func SetUserInfo(r *http.Request, user store.User) *http.Request

SetUserInfo sets user into request context

Types

type Node

type Node struct {
	Comment store.Comment `json:"comment"`
	Replies []*Node       `json:"replies,omitempty"`
	// contains filtered or unexported fields
}

Node is a comment with optional replies

type Tree

type Tree struct {
	Nodes []*Node        `json:"comments"`
	Info  store.PostInfo `json:"info,omitempty"`
}

Tree is formatter making tree from the list of comments

func MakeTree

func MakeTree(comments []store.Comment, sortType string, readOnlyAge int) *Tree

MakeTree gets unsorted list of comments and produces Tree It will make store.PostInfo by itself and will mark Info.ReadOnly based on passed readOnlyAge Tree maker is local and has no access to the data store. By this reason it has to make Info and won't be able to handle store's read-only status. This status should be set by caller.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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