mattermost/server/public/pluginapi/grpc/generated/go/pluginapiv1/hooks_http.pb.go
Nick Misasi 5c7aecda49 feat(08-02): extend protobuf contract for response streaming + flush
Add flush field to ServeHTTPResponse for best-effort HTTP flush support.
Update ServeHTTPResponse and ServeHTTPResponseInit with comprehensive
documentation of streaming invariants, message ordering, and status
code validation rules.

Changes:
- Add flush boolean field (field 4) to ServeHTTPResponse
- Document response streaming invariants (init-once, header locking)
- Document status code validation (100-999 range, 0 defaults to 200)
- Regenerate Go and Python protobuf code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 14:34:36 -05:00

540 lines
18 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.6
// protoc v6.33.4
// source: hooks_http.proto
package pluginapiv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// HTTPHeader represents a single HTTP header with potentially multiple values.
// HTTP allows multiple headers with the same key (e.g., Set-Cookie).
type HTTPHeader struct {
state protoimpl.MessageState `protogen:"open.v1"`
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
Values []string `protobuf:"bytes,2,rep,name=values,proto3" json:"values,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *HTTPHeader) Reset() {
*x = HTTPHeader{}
mi := &file_hooks_http_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *HTTPHeader) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HTTPHeader) ProtoMessage() {}
func (x *HTTPHeader) ProtoReflect() protoreflect.Message {
mi := &file_hooks_http_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HTTPHeader.ProtoReflect.Descriptor instead.
func (*HTTPHeader) Descriptor() ([]byte, []int) {
return file_hooks_http_proto_rawDescGZIP(), []int{0}
}
func (x *HTTPHeader) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
func (x *HTTPHeader) GetValues() []string {
if x != nil {
return x.Values
}
return nil
}
// ServeHTTPRequest is a streaming message sent from Go to Python.
// The first message contains request metadata; subsequent messages contain body chunks.
type ServeHTTPRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Request metadata (set only in first message of stream)
Init *ServeHTTPRequestInit `protobuf:"bytes,1,opt,name=init,proto3" json:"init,omitempty"`
// Body chunk (may be empty in first message or if no body)
BodyChunk []byte `protobuf:"bytes,2,opt,name=body_chunk,json=bodyChunk,proto3" json:"body_chunk,omitempty"`
// Indicates this is the last body chunk.
// If true, no more body chunks will follow.
// This may be set on the first message if the request has no body.
BodyComplete bool `protobuf:"varint,3,opt,name=body_complete,json=bodyComplete,proto3" json:"body_complete,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ServeHTTPRequest) Reset() {
*x = ServeHTTPRequest{}
mi := &file_hooks_http_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ServeHTTPRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ServeHTTPRequest) ProtoMessage() {}
func (x *ServeHTTPRequest) ProtoReflect() protoreflect.Message {
mi := &file_hooks_http_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ServeHTTPRequest.ProtoReflect.Descriptor instead.
func (*ServeHTTPRequest) Descriptor() ([]byte, []int) {
return file_hooks_http_proto_rawDescGZIP(), []int{1}
}
func (x *ServeHTTPRequest) GetInit() *ServeHTTPRequestInit {
if x != nil {
return x.Init
}
return nil
}
func (x *ServeHTTPRequest) GetBodyChunk() []byte {
if x != nil {
return x.BodyChunk
}
return nil
}
func (x *ServeHTTPRequest) GetBodyComplete() bool {
if x != nil {
return x.BodyComplete
}
return false
}
// ServeHTTPRequestInit contains HTTP request metadata.
// Sent as part of the first ServeHTTPRequest message.
type ServeHTTPRequestInit struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Plugin context for this request
PluginContext *PluginContext `protobuf:"bytes,1,opt,name=plugin_context,json=pluginContext,proto3" json:"plugin_context,omitempty"`
// HTTP method (GET, POST, PUT, DELETE, etc.)
Method string `protobuf:"bytes,2,opt,name=method,proto3" json:"method,omitempty"`
// Full URL as string (e.g., "http://localhost:8065/plugins/myid/api/v1/foo?bar=baz")
Url string `protobuf:"bytes,3,opt,name=url,proto3" json:"url,omitempty"`
// Protocol version (e.g., "HTTP/1.1", "HTTP/2.0")
Proto string `protobuf:"bytes,4,opt,name=proto,proto3" json:"proto,omitempty"`
// Major version number (e.g., 1 for HTTP/1.1)
ProtoMajor int32 `protobuf:"varint,5,opt,name=proto_major,json=protoMajor,proto3" json:"proto_major,omitempty"`
// Minor version number (e.g., 1 for HTTP/1.1)
ProtoMinor int32 `protobuf:"varint,6,opt,name=proto_minor,json=protoMinor,proto3" json:"proto_minor,omitempty"`
// HTTP headers (supports multi-value headers)
Headers []*HTTPHeader `protobuf:"bytes,7,rep,name=headers,proto3" json:"headers,omitempty"`
// Host header value (may differ from URL host for virtual hosting)
Host string `protobuf:"bytes,8,opt,name=host,proto3" json:"host,omitempty"`
// Remote address of the client (e.g., "192.168.1.1:12345")
RemoteAddr string `protobuf:"bytes,9,opt,name=remote_addr,json=remoteAddr,proto3" json:"remote_addr,omitempty"`
// The original request URI as received (includes query string)
RequestUri string `protobuf:"bytes,10,opt,name=request_uri,json=requestUri,proto3" json:"request_uri,omitempty"`
// Content-Length if known, -1 if unknown/chunked
ContentLength int64 `protobuf:"varint,11,opt,name=content_length,json=contentLength,proto3" json:"content_length,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ServeHTTPRequestInit) Reset() {
*x = ServeHTTPRequestInit{}
mi := &file_hooks_http_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ServeHTTPRequestInit) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ServeHTTPRequestInit) ProtoMessage() {}
func (x *ServeHTTPRequestInit) ProtoReflect() protoreflect.Message {
mi := &file_hooks_http_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ServeHTTPRequestInit.ProtoReflect.Descriptor instead.
func (*ServeHTTPRequestInit) Descriptor() ([]byte, []int) {
return file_hooks_http_proto_rawDescGZIP(), []int{2}
}
func (x *ServeHTTPRequestInit) GetPluginContext() *PluginContext {
if x != nil {
return x.PluginContext
}
return nil
}
func (x *ServeHTTPRequestInit) GetMethod() string {
if x != nil {
return x.Method
}
return ""
}
func (x *ServeHTTPRequestInit) GetUrl() string {
if x != nil {
return x.Url
}
return ""
}
func (x *ServeHTTPRequestInit) GetProto() string {
if x != nil {
return x.Proto
}
return ""
}
func (x *ServeHTTPRequestInit) GetProtoMajor() int32 {
if x != nil {
return x.ProtoMajor
}
return 0
}
func (x *ServeHTTPRequestInit) GetProtoMinor() int32 {
if x != nil {
return x.ProtoMinor
}
return 0
}
func (x *ServeHTTPRequestInit) GetHeaders() []*HTTPHeader {
if x != nil {
return x.Headers
}
return nil
}
func (x *ServeHTTPRequestInit) GetHost() string {
if x != nil {
return x.Host
}
return ""
}
func (x *ServeHTTPRequestInit) GetRemoteAddr() string {
if x != nil {
return x.RemoteAddr
}
return ""
}
func (x *ServeHTTPRequestInit) GetRequestUri() string {
if x != nil {
return x.RequestUri
}
return ""
}
func (x *ServeHTTPRequestInit) GetContentLength() int64 {
if x != nil {
return x.ContentLength
}
return 0
}
// ServeHTTPResponse is a streaming message sent from Python to Go.
// The first message contains response metadata; subsequent messages contain body chunks.
//
// RESPONSE STREAMING INVARIANTS:
// - Exactly one response-init must be sent (explicitly or implicitly on first body write)
// - Status code defaults to 200 if not set before first body write
// - Headers are only accepted before the first body write (locked after init)
// - Flush may be sent any time after response-init; Go ignores if underlying writer doesn't support it
// - body_complete=true signals end of response; no more messages should follow
//
// MESSAGE ORDERING:
// 1. First message: init (status + headers) with optional body_chunk
// 2. Subsequent messages: body_chunk and/or flush
// 3. Final message: body_complete=true (may include final body_chunk)
type ServeHTTPResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Response metadata (set only in first message of stream)
// MUST be present in first message. Status code range must be 100-999.
Init *ServeHTTPResponseInit `protobuf:"bytes,1,opt,name=init,proto3" json:"init,omitempty"`
// Body chunk (may be empty in first message or if no body)
// Recommended max chunk size: 64KB
BodyChunk []byte `protobuf:"bytes,2,opt,name=body_chunk,json=bodyChunk,proto3" json:"body_chunk,omitempty"`
// Indicates this is the last body chunk.
// If true, no more body chunks will follow.
BodyComplete bool `protobuf:"varint,3,opt,name=body_complete,json=bodyComplete,proto3" json:"body_complete,omitempty"`
// Request an immediate flush of buffered response data to the client.
// Best-effort: Go will call http.Flusher.Flush() if the underlying
// ResponseWriter supports it; otherwise silently ignored.
// This matches Go plugin RPC behavior (see plugin/http.go).
Flush bool `protobuf:"varint,4,opt,name=flush,proto3" json:"flush,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ServeHTTPResponse) Reset() {
*x = ServeHTTPResponse{}
mi := &file_hooks_http_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ServeHTTPResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ServeHTTPResponse) ProtoMessage() {}
func (x *ServeHTTPResponse) ProtoReflect() protoreflect.Message {
mi := &file_hooks_http_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ServeHTTPResponse.ProtoReflect.Descriptor instead.
func (*ServeHTTPResponse) Descriptor() ([]byte, []int) {
return file_hooks_http_proto_rawDescGZIP(), []int{3}
}
func (x *ServeHTTPResponse) GetInit() *ServeHTTPResponseInit {
if x != nil {
return x.Init
}
return nil
}
func (x *ServeHTTPResponse) GetBodyChunk() []byte {
if x != nil {
return x.BodyChunk
}
return nil
}
func (x *ServeHTTPResponse) GetBodyComplete() bool {
if x != nil {
return x.BodyComplete
}
return false
}
func (x *ServeHTTPResponse) GetFlush() bool {
if x != nil {
return x.Flush
}
return false
}
// ServeHTTPResponseInit contains HTTP response metadata.
// Sent as part of the first ServeHTTPResponse message.
//
// VALIDATION:
// - status_code must be in range 100-999 (per HTTP spec)
// - Invalid status codes cause Go to return 500 and log an error
// - status_code of 0 defaults to 200 OK
type ServeHTTPResponseInit struct {
state protoimpl.MessageState `protogen:"open.v1"`
// HTTP status code (e.g., 200, 404, 500)
// Must be in range 100-999. 0 defaults to 200.
// Invalid values (< 100 or > 999) will be rejected with 500 error.
StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"`
// HTTP response headers (supports multi-value headers)
// Headers are immutable after init is sent.
Headers []*HTTPHeader `protobuf:"bytes,2,rep,name=headers,proto3" json:"headers,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ServeHTTPResponseInit) Reset() {
*x = ServeHTTPResponseInit{}
mi := &file_hooks_http_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ServeHTTPResponseInit) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ServeHTTPResponseInit) ProtoMessage() {}
func (x *ServeHTTPResponseInit) ProtoReflect() protoreflect.Message {
mi := &file_hooks_http_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ServeHTTPResponseInit.ProtoReflect.Descriptor instead.
func (*ServeHTTPResponseInit) Descriptor() ([]byte, []int) {
return file_hooks_http_proto_rawDescGZIP(), []int{4}
}
func (x *ServeHTTPResponseInit) GetStatusCode() int32 {
if x != nil {
return x.StatusCode
}
return 0
}
func (x *ServeHTTPResponseInit) GetHeaders() []*HTTPHeader {
if x != nil {
return x.Headers
}
return nil
}
var File_hooks_http_proto protoreflect.FileDescriptor
const file_hooks_http_proto_rawDesc = "" +
"\n" +
"\x10hooks_http.proto\x12\x17mattermost.pluginapi.v1\x1a\x12hooks_common.proto\"6\n" +
"\n" +
"HTTPHeader\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x16\n" +
"\x06values\x18\x02 \x03(\tR\x06values\"\x99\x01\n" +
"\x10ServeHTTPRequest\x12A\n" +
"\x04init\x18\x01 \x01(\v2-.mattermost.pluginapi.v1.ServeHTTPRequestInitR\x04init\x12\x1d\n" +
"\n" +
"body_chunk\x18\x02 \x01(\fR\tbodyChunk\x12#\n" +
"\rbody_complete\x18\x03 \x01(\bR\fbodyComplete\"\xa3\x03\n" +
"\x14ServeHTTPRequestInit\x12M\n" +
"\x0eplugin_context\x18\x01 \x01(\v2&.mattermost.pluginapi.v1.PluginContextR\rpluginContext\x12\x16\n" +
"\x06method\x18\x02 \x01(\tR\x06method\x12\x10\n" +
"\x03url\x18\x03 \x01(\tR\x03url\x12\x14\n" +
"\x05proto\x18\x04 \x01(\tR\x05proto\x12\x1f\n" +
"\vproto_major\x18\x05 \x01(\x05R\n" +
"protoMajor\x12\x1f\n" +
"\vproto_minor\x18\x06 \x01(\x05R\n" +
"protoMinor\x12=\n" +
"\aheaders\x18\a \x03(\v2#.mattermost.pluginapi.v1.HTTPHeaderR\aheaders\x12\x12\n" +
"\x04host\x18\b \x01(\tR\x04host\x12\x1f\n" +
"\vremote_addr\x18\t \x01(\tR\n" +
"remoteAddr\x12\x1f\n" +
"\vrequest_uri\x18\n" +
" \x01(\tR\n" +
"requestUri\x12%\n" +
"\x0econtent_length\x18\v \x01(\x03R\rcontentLength\"\xb1\x01\n" +
"\x11ServeHTTPResponse\x12B\n" +
"\x04init\x18\x01 \x01(\v2..mattermost.pluginapi.v1.ServeHTTPResponseInitR\x04init\x12\x1d\n" +
"\n" +
"body_chunk\x18\x02 \x01(\fR\tbodyChunk\x12#\n" +
"\rbody_complete\x18\x03 \x01(\bR\fbodyComplete\x12\x14\n" +
"\x05flush\x18\x04 \x01(\bR\x05flush\"w\n" +
"\x15ServeHTTPResponseInit\x12\x1f\n" +
"\vstatus_code\x18\x01 \x01(\x05R\n" +
"statusCode\x12=\n" +
"\aheaders\x18\x02 \x03(\v2#.mattermost.pluginapi.v1.HTTPHeaderR\aheadersBXZVgithub.com/mattermost/mattermost/server/public/pluginapi/grpc/generated/go/pluginapiv1b\x06proto3"
var (
file_hooks_http_proto_rawDescOnce sync.Once
file_hooks_http_proto_rawDescData []byte
)
func file_hooks_http_proto_rawDescGZIP() []byte {
file_hooks_http_proto_rawDescOnce.Do(func() {
file_hooks_http_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_hooks_http_proto_rawDesc), len(file_hooks_http_proto_rawDesc)))
})
return file_hooks_http_proto_rawDescData
}
var file_hooks_http_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_hooks_http_proto_goTypes = []any{
(*HTTPHeader)(nil), // 0: mattermost.pluginapi.v1.HTTPHeader
(*ServeHTTPRequest)(nil), // 1: mattermost.pluginapi.v1.ServeHTTPRequest
(*ServeHTTPRequestInit)(nil), // 2: mattermost.pluginapi.v1.ServeHTTPRequestInit
(*ServeHTTPResponse)(nil), // 3: mattermost.pluginapi.v1.ServeHTTPResponse
(*ServeHTTPResponseInit)(nil), // 4: mattermost.pluginapi.v1.ServeHTTPResponseInit
(*PluginContext)(nil), // 5: mattermost.pluginapi.v1.PluginContext
}
var file_hooks_http_proto_depIdxs = []int32{
2, // 0: mattermost.pluginapi.v1.ServeHTTPRequest.init:type_name -> mattermost.pluginapi.v1.ServeHTTPRequestInit
5, // 1: mattermost.pluginapi.v1.ServeHTTPRequestInit.plugin_context:type_name -> mattermost.pluginapi.v1.PluginContext
0, // 2: mattermost.pluginapi.v1.ServeHTTPRequestInit.headers:type_name -> mattermost.pluginapi.v1.HTTPHeader
4, // 3: mattermost.pluginapi.v1.ServeHTTPResponse.init:type_name -> mattermost.pluginapi.v1.ServeHTTPResponseInit
0, // 4: mattermost.pluginapi.v1.ServeHTTPResponseInit.headers:type_name -> mattermost.pluginapi.v1.HTTPHeader
5, // [5:5] is the sub-list for method output_type
5, // [5:5] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { file_hooks_http_proto_init() }
func file_hooks_http_proto_init() {
if File_hooks_http_proto != nil {
return
}
file_hooks_common_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_hooks_http_proto_rawDesc), len(file_hooks_http_proto_rawDesc)),
NumEnums: 0,
NumMessages: 5,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_hooks_http_proto_goTypes,
DependencyIndexes: file_hooks_http_proto_depIdxs,
MessageInfos: file_hooks_http_proto_msgTypes,
}.Build()
File_hooks_http_proto = out.File
file_hooks_http_proto_goTypes = nil
file_hooks_http_proto_depIdxs = nil
}