api4

package
v5.22.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 License: AGPL-3.0, Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FILE_TEAM_ID = "noteam"

	PREVIEW_IMAGE_TYPE   = "image/jpeg"
	THUMBNAIL_IMAGE_TYPE = "image/jpeg"
)
View Source
const (
	REDIRECT_LOCATION_CACHE_SIZE = 10000
	DEFAULT_SERVER_BUSY_SECONDS  = 3600
	MAX_SERVER_BUSY_SECONDS      = 86400
)
View Source
const (
	EMOJI_MAX_AUTOCOMPLETE_ITEMS = 100
)
View Source
const OPEN_GRAPH_METADATA_CACHE_SIZE = 10000

Variables

View Source
var MEDIA_CONTENT_TYPES = [...]string{
	"image/jpeg",
	"image/png",
	"image/bmp",
	"image/gif",
	"image/tiff",
	"video/avi",
	"video/mpeg",
	"video/mp4",
	"audio/mpeg",
	"audio/wav",
}
View Source
var ReturnStatusOK = web.ReturnStatusOK
View Source
var UNSAFE_CONTENT_TYPES = [...]string{
	"application/javascript",
	"application/ecmascript",
	"text/javascript",
	"text/ecmascript",
	"application/x-javascript",
	"text/html",
}

Functions

func Logout

func Logout(c *Context, w http.ResponseWriter, r *http.Request)

Types

type API

type API struct {
	ConfigService       configservice.ConfigService
	GetGlobalAppOptions app.AppOptionCreator
	BaseRoutes          *Routes
}

func Init

func Init(configservice configservice.ConfigService, globalOptionsFunc app.AppOptionCreator, root *mux.Router) *API

func (*API) ApiHandler

func (api *API) ApiHandler(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

ApiHandler provides a handler for API endpoints which do not require the user to be logged in order for access to be granted.

func (*API) ApiHandlerTrustRequester

func (api *API) ApiHandlerTrustRequester(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

ApiHandlerTrustRequester provides a handler for API endpoints which do not require the user to be logged in and are allowed to be requested directly rather than via javascript/XMLHttpRequest, such as site branding images or the websocket.

func (*API) ApiSessionRequired

func (api *API) ApiSessionRequired(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

ApiSessionRequired provides a handler for API endpoints which require the user to be logged in in order for access to be granted.

func (*API) ApiSessionRequiredDisableWhenBusy

func (api *API) ApiSessionRequiredDisableWhenBusy(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

DisableWhenBusy provides a handler for API endpoints which should be disabled when the server is under load, responding with HTTP 503 (Service Unavailable).

func (*API) ApiSessionRequiredMfa

func (api *API) ApiSessionRequiredMfa(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

ApiSessionRequiredMfa provides a handler for API endpoints which require a logged-in user session but when accessed, if MFA is enabled, the MFA process is not yet complete, and therefore the requirement to have completed the MFA authentication must be waived.

func (*API) ApiSessionRequiredTrustRequester

func (api *API) ApiSessionRequiredTrustRequester(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

ApiSessionRequiredTrustRequester provides a handler for API endpoints which do require the user to be logged in and are allowed to be requested directly rather than via javascript/XMLHttpRequest, such as emoji or file uploads.

func (*API) Handle404

func (api *API) Handle404(w http.ResponseWriter, r *http.Request)

func (*API) InitAction

func (api *API) InitAction()

func (*API) InitBrand

func (api *API) InitBrand()

func (*API) InitCluster

func (api *API) InitCluster()

func (*API) InitCommand

func (api *API) InitCommand()

func (*API) InitCompliance

func (api *API) InitCompliance()

func (*API) InitConfig

func (api *API) InitConfig()

func (*API) InitDataRetention

func (api *API) InitDataRetention()

func (*API) InitElasticsearch

func (api *API) InitElasticsearch()

func (*API) InitEmoji

func (api *API) InitEmoji()

func (*API) InitFile

func (api *API) InitFile()

func (*API) InitImage

func (api *API) InitImage()

func (*API) InitJob

func (api *API) InitJob()

func (*API) InitLdap

func (api *API) InitLdap()

func (*API) InitLicense

func (api *API) InitLicense()

func (*API) InitOAuth

func (api *API) InitOAuth()

func (*API) InitOpenGraph

func (api *API) InitOpenGraph()

func (*API) InitPreference

func (api *API) InitPreference()

func (*API) InitReaction

func (api *API) InitReaction()

func (*API) InitRole

func (api *API) InitRole()

func (*API) InitSaml

func (api *API) InitSaml()

func (*API) InitScheme

func (api *API) InitScheme()

func (*API) InitStatus

func (api *API) InitStatus()

func (*API) InitSystem

func (api *API) InitSystem()

func (*API) InitTermsOfService

func (api *API) InitTermsOfService()

func (*API) InitUser

func (api *API) InitUser()

func (*API) InitWebSocket

func (api *API) InitWebSocket()

func (*API) InitWebhook

func (api *API) InitWebhook()

type Context

type Context = web.Context

type Routes

type Routes struct {
	Root    *mux.Router // ”
	ApiRoot *mux.Router // 'api/v4'

	Users          *mux.Router // 'api/v4/users'
	User           *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}'
	UserByUsername *mux.Router // 'api/v4/users/username/{username:[A-Za-z0-9_-\.]+}'
	UserByEmail    *mux.Router // 'api/v4/users/email/{email}'

	Bots *mux.Router // 'api/v4/bots'
	Bot  *mux.Router // 'api/v4/bots/{bot_user_id:[A-Za-z0-9]+}'

	Teams              *mux.Router // 'api/v4/teams'
	TeamsForUser       *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/teams'
	Team               *mux.Router // 'api/v4/teams/{team_id:[A-Za-z0-9]+}'
	TeamForUser        *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/teams/{team_id:[A-Za-z0-9]+}'
	TeamByName         *mux.Router // 'api/v4/teams/name/{team_name:[A-Za-z0-9_-]+}'
	TeamMembers        *mux.Router // 'api/v4/teams/{team_id:[A-Za-z0-9_-]+}/members'
	TeamMember         *mux.Router // 'api/v4/teams/{team_id:[A-Za-z0-9_-]+}/members/{user_id:[A-Za-z0-9_-]+}'
	TeamMembersForUser *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/teams/members'

	Channels                 *mux.Router // 'api/v4/channels'
	Channel                  *mux.Router // 'api/v4/channels/{channel_id:[A-Za-z0-9]+}'
	ChannelForUser           *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/channels/{channel_id:[A-Za-z0-9]+}'
	ChannelByName            *mux.Router // 'api/v4/teams/{team_id:[A-Za-z0-9]+}/channels/name/{channel_name:[A-Za-z0-9_-]+}'
	ChannelByNameForTeamName *mux.Router // 'api/v4/teams/name/{team_name:[A-Za-z0-9_-]+}/channels/name/{channel_name:[A-Za-z0-9_-]+}'
	ChannelsForTeam          *mux.Router // 'api/v4/teams/{team_id:[A-Za-z0-9]+}/channels'
	ChannelMembers           *mux.Router // 'api/v4/channels/{channel_id:[A-Za-z0-9]+}/members'
	ChannelMember            *mux.Router // 'api/v4/channels/{channel_id:[A-Za-z0-9]+}/members/{user_id:[A-Za-z0-9]+}'
	ChannelMembersForUser    *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/teams/{team_id:[A-Za-z0-9]+}/channels/members'
	ChannelModerations       *mux.Router // 'api/v4/channels/{channel_id:[A-Za-z0-9]+}/moderations'

	Posts           *mux.Router // 'api/v4/posts'
	Post            *mux.Router // 'api/v4/posts/{post_id:[A-Za-z0-9]+}'
	PostsForChannel *mux.Router // 'api/v4/channels/{channel_id:[A-Za-z0-9]+}/posts'
	PostsForUser    *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/posts'
	PostForUser     *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/posts/{post_id:[A-Za-z0-9]+}'

	Files *mux.Router // 'api/v4/files'
	File  *mux.Router // 'api/v4/files/{file_id:[A-Za-z0-9]+}'

	Plugins *mux.Router // 'api/v4/plugins'
	Plugin  *mux.Router // 'api/v4/plugins/{plugin_id:[A-Za-z0-9_-]+}'

	PublicFile *mux.Router // 'files/{file_id:[A-Za-z0-9]+}/public'

	Commands *mux.Router // 'api/v4/commands'
	Command  *mux.Router // 'api/v4/commands/{command_id:[A-Za-z0-9]+}'

	Hooks         *mux.Router // 'api/v4/hooks'
	IncomingHooks *mux.Router // 'api/v4/hooks/incoming'
	IncomingHook  *mux.Router // 'api/v4/hooks/incoming/{hook_id:[A-Za-z0-9]+}'
	OutgoingHooks *mux.Router // 'api/v4/hooks/outgoing'
	OutgoingHook  *mux.Router // 'api/v4/hooks/outgoing/{hook_id:[A-Za-z0-9]+}'

	OAuth     *mux.Router // 'api/v4/oauth'
	OAuthApps *mux.Router // 'api/v4/oauth/apps'
	OAuthApp  *mux.Router // 'api/v4/oauth/apps/{app_id:[A-Za-z0-9]+}'

	OpenGraph *mux.Router // 'api/v4/opengraph'

	SAML       *mux.Router // 'api/v4/saml'
	Compliance *mux.Router // 'api/v4/compliance'
	Cluster    *mux.Router // 'api/v4/cluster'

	Image *mux.Router // 'api/v4/image'

	LDAP *mux.Router // 'api/v4/ldap'

	Elasticsearch *mux.Router // 'api/v4/elasticsearch'

	DataRetention *mux.Router // 'api/v4/data_retention'

	Brand *mux.Router // 'api/v4/brand'

	System *mux.Router // 'api/v4/system'

	Jobs *mux.Router // 'api/v4/jobs'

	Preferences *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/preferences'

	License *mux.Router // 'api/v4/license'

	Public *mux.Router // 'api/v4/public'

	Reactions *mux.Router // 'api/v4/reactions'

	Roles   *mux.Router // 'api/v4/roles'
	Schemes *mux.Router // 'api/v4/schemes'

	Emojis      *mux.Router // 'api/v4/emoji'
	Emoji       *mux.Router // 'api/v4/emoji/{emoji_id:[A-Za-z0-9]+}'
	EmojiByName *mux.Router // 'api/v4/emoji/name/{emoji_name:[A-Za-z0-9_-\.]+}'

	ReactionByNameForPostForUser *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/posts/{post_id:[A-Za-z0-9]+}/reactions/{emoji_name:[A-Za-z0-9_-+]+}'

	TermsOfService *mux.Router // 'api/v4/terms_of_service
	Groups         *mux.Router // 'api/v4/groups'
}

Jump to

Keyboard shortcuts

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