2021-08-28 15:27:24 +00:00
|
|
|
package plugins
|
|
|
|
|
|
|
|
import "net/http"
|
|
|
|
|
|
|
|
type (
|
2024-01-01 16:52:18 +00:00
|
|
|
// HTTPRouteParamDocumentation documents parameters expected by a
|
|
|
|
// HTTP route and to be documented in the API documentation
|
2021-08-28 15:27:24 +00:00
|
|
|
HTTPRouteParamDocumentation struct {
|
|
|
|
Description string
|
|
|
|
Name string
|
|
|
|
Required bool
|
|
|
|
Type string
|
|
|
|
}
|
|
|
|
|
2024-01-01 16:52:18 +00:00
|
|
|
// HTTPRouteRegistrationArgs defines the HTTP route to be added in
|
|
|
|
// using the HTTPRouteRegistrationFunc
|
2021-08-28 15:27:24 +00:00
|
|
|
HTTPRouteRegistrationArgs struct {
|
2021-10-22 20:27:03 +00:00
|
|
|
Accept []string
|
2021-09-22 13:36:45 +00:00
|
|
|
Description string
|
|
|
|
HandlerFunc http.HandlerFunc
|
|
|
|
IsPrefix bool
|
|
|
|
Method string
|
|
|
|
Module string
|
|
|
|
Name string
|
|
|
|
Path string
|
|
|
|
QueryParams []HTTPRouteParamDocumentation
|
|
|
|
RequiresEditorsAuth bool
|
2021-10-23 15:22:58 +00:00
|
|
|
RequiresWriteAuth bool
|
2021-09-22 13:36:45 +00:00
|
|
|
ResponseType HTTPRouteResponseType
|
|
|
|
RouteParams []HTTPRouteParamDocumentation
|
|
|
|
SkipDocumentation bool
|
2021-08-28 15:27:24 +00:00
|
|
|
}
|
|
|
|
|
2024-01-01 16:52:18 +00:00
|
|
|
// HTTPRouteResponseType pre-defines response types known to the API
|
|
|
|
// documentation
|
2021-08-28 15:27:24 +00:00
|
|
|
HTTPRouteResponseType uint64
|
|
|
|
|
2024-01-01 16:52:18 +00:00
|
|
|
// HTTPRouteRegistrationFunc is passed from the bot to the
|
|
|
|
// plugins RegisterFunc to register a new route in the API router
|
2021-08-28 15:27:24 +00:00
|
|
|
HTTPRouteRegistrationFunc func(HTTPRouteRegistrationArgs) error
|
|
|
|
)
|
|
|
|
|
2024-01-01 16:52:18 +00:00
|
|
|
// Enum of known HTTPRouteResponseType
|
2021-08-28 15:27:24 +00:00
|
|
|
const (
|
|
|
|
HTTPRouteResponseTypeNo200 HTTPRouteResponseType = iota
|
|
|
|
HTTPRouteResponseTypeTextPlain
|
|
|
|
HTTPRouteResponseTypeJSON
|
2021-10-22 20:27:03 +00:00
|
|
|
HTTPRouteResponseTypeMultiple
|
2021-08-28 15:27:24 +00:00
|
|
|
)
|