server

package
v0.18.6 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Test v0.10.0 59843169c5648f7290858df111734e016be54102 -- Code generated by webrpc-gen with golang generator. DO NOT EDIT.

webrpc-gen -schema=./schema/test.ridl -target=golang -pkg=server -server -out=./server/server.gen.go

Index

Constants

This section is empty.

Variables

View Source
var (
	HTTPResponseWriterCtxKey = &contextKey{"HTTPResponseWriter"}

	HTTPRequestCtxKey = &contextKey{"HTTPRequest"}

	ServiceNameCtxKey = &contextKey{"ServiceName"}

	MethodNameCtxKey = &contextKey{"MethodName"}
)
View Source
var (
	ErrWebrpcEndpoint           = WebRPCError{Code: 0, Name: "WebrpcEndpoint", Message: "endpoint error", HTTPStatus: 400}
	ErrWebrpcRequestFailed      = WebRPCError{Code: -1, Name: "WebrpcRequestFailed", Message: "request failed", HTTPStatus: 400}
	ErrWebrpcBadRoute           = WebRPCError{Code: -2, Name: "WebrpcBadRoute", Message: "bad route", HTTPStatus: 404}
	ErrWebrpcBadMethod          = WebRPCError{Code: -3, Name: "WebrpcBadMethod", Message: "bad method", HTTPStatus: 405}
	ErrWebrpcBadRequest         = WebRPCError{Code: -4, Name: "WebrpcBadRequest", Message: "bad request", HTTPStatus: 400}
	ErrWebrpcBadResponse        = WebRPCError{Code: -5, Name: "WebrpcBadResponse", Message: "bad response", HTTPStatus: 500}
	ErrWebrpcServerPanic        = WebRPCError{Code: -6, Name: "WebrpcServerPanic", Message: "server panic", HTTPStatus: 500}
	ErrWebrpcInternalError      = WebRPCError{Code: -7, Name: "WebrpcInternalError", Message: "internal error", HTTPStatus: 500}
	ErrWebrpcClientDisconnected = WebRPCError{Code: -8, Name: "WebrpcClientDisconnected", Message: "client disconnected", HTTPStatus: 400}
	ErrWebrpcStreamLost         = WebRPCError{Code: -9, Name: "WebrpcStreamLost", Message: "stream lost", HTTPStatus: 400}
	ErrWebrpcStreamFinished     = WebRPCError{Code: -10, Name: "WebrpcStreamFinished", Message: "stream finished", HTTPStatus: 200}
)

Webrpc errors

View Source
var (
	ErrUnauthorized    = WebRPCError{Code: 1, Name: "Unauthorized", Message: "unauthorized", HTTPStatus: 401}
	ErrExpiredToken    = WebRPCError{Code: 2, Name: "ExpiredToken", Message: "expired token", HTTPStatus: 401}
	ErrInvalidToken    = WebRPCError{Code: 3, Name: "InvalidToken", Message: "invalid token", HTTPStatus: 401}
	ErrDeactivated     = WebRPCError{Code: 4, Name: "Deactivated", Message: "account deactivated", HTTPStatus: 403}
	ErrConfirmAccount  = WebRPCError{Code: 5, Name: "ConfirmAccount", Message: "confirm your email", HTTPStatus: 403}
	ErrAccessDenied    = WebRPCError{Code: 6, Name: "AccessDenied", Message: "access denied", HTTPStatus: 403}
	ErrMissingArgument = WebRPCError{Code: 7, Name: "MissingArgument", Message: "missing argument", HTTPStatus: 400}
	ErrUnexpectedValue = WebRPCError{Code: 8, Name: "UnexpectedValue", Message: "unexpected value", HTTPStatus: 400}
	ErrRateLimited     = WebRPCError{Code: 100, Name: "RateLimited", Message: "too many requests", HTTPStatus: 429}
	ErrDatabaseDown    = WebRPCError{Code: 101, Name: "DatabaseDown", Message: "service outage", HTTPStatus: 503}
	ErrElasticDown     = WebRPCError{Code: 102, Name: "ElasticDown", Message: "search is degraded", HTTPStatus: 503}
	ErrNotImplemented  = WebRPCError{Code: 103, Name: "NotImplemented", Message: "not implemented", HTTPStatus: 501}
	ErrUserNotFound    = WebRPCError{Code: 200, Name: "UserNotFound", Message: "user not found", HTTPStatus: 400}
	ErrUserBusy        = WebRPCError{Code: 201, Name: "UserBusy", Message: "user busy", HTTPStatus: 400}
	ErrInvalidUsername = WebRPCError{Code: 202, Name: "InvalidUsername", Message: "invalid username", HTTPStatus: 400}
	ErrFileTooBig      = WebRPCError{Code: 300, Name: "FileTooBig", Message: "file is too big (max 1GB)", HTTPStatus: 400}
	ErrFileInfected    = WebRPCError{Code: 301, Name: "FileInfected", Message: "file is infected", HTTPStatus: 400}
	ErrFileType        = WebRPCError{Code: 302, Name: "FileType", Message: "unsupported file type", HTTPStatus: 400}
)

Schema errors

View Source
var Status_name = map[uint32]string{
	0: "AVAILABLE",
	1: "NOT_AVAILABLE",
}
View Source
var Status_value = map[string]uint32{
	"AVAILABLE":     0,
	"NOT_AVAILABLE": 1,
}
View Source
var WebRPCServices = map[string][]string{
	"TestApi": {
		"GetEmpty",
		"GetError",
		"GetOne",
		"SendOne",
		"GetMulti",
		"SendMulti",
		"GetComplex",
		"SendComplex",
		"GetSchemaError",
	},
}

Functions

func MethodNameFromContext added in v0.13.1

func MethodNameFromContext(ctx context.Context) string

func NewTestApiServer added in v0.10.0

func NewTestApiServer(svc TestApi) *testApiServer

func RequestFromContext added in v0.13.1

func RequestFromContext(ctx context.Context) *http.Request

func RespondWithError

func RespondWithError(w http.ResponseWriter, err error)

func ResponseWriterFromContext added in v0.13.1

func ResponseWriterFromContext(ctx context.Context) http.ResponseWriter

func RunTestServer added in v0.10.0

func RunTestServer(addr string, timeout time.Duration) (*testServer, error)

func ServiceNameFromContext added in v0.13.1

func ServiceNameFromContext(ctx context.Context) string

func WebRPCSchemaHash

func WebRPCSchemaHash() string

Schema hash generated from your RIDL schema

func WebRPCSchemaVersion

func WebRPCSchemaVersion() string

Schema version of your RIDL schema

func WebRPCVersion

func WebRPCVersion() string

WebRPC description and code-gen version

Types

type Complex added in v0.10.0

type Complex struct {
	Meta              map[string]interface{}       `json:"meta"`
	MetaNestedExample map[string]map[string]uint32 `json:"metaNestedExample"`
	NamesList         []string                     `json:"namesList"`
	NumsList          []int64                      `json:"numsList"`
	DoubleArray       [][]string                   `json:"doubleArray"`
	ListOfMaps        []map[string]uint32          `json:"listOfMaps"`
	ListOfUsers       []*User                      `json:"listOfUsers"`
	MapOfUsers        map[string]*User             `json:"mapOfUsers"`
	User              *User                        `json:"user"`
	Status            Status                       `json:"status"`
}

type Simple added in v0.10.0

type Simple struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type Status

type Status uint32
const (
	Status_AVAILABLE     Status = 0
	Status_NOT_AVAILABLE Status = 1
)

func (*Status) Is added in v0.14.0

func (x *Status) Is(values ...Status) bool

func (Status) MarshalText added in v0.12.1

func (x Status) MarshalText() ([]byte, error)

func (Status) String

func (x Status) String() string

func (*Status) UnmarshalText added in v0.12.1

func (x *Status) UnmarshalText(b []byte) error

type TestApi added in v0.10.0

type TestApi interface {
	GetEmpty(ctx context.Context) error
	GetError(ctx context.Context) error
	GetOne(ctx context.Context) (*Simple, error)
	SendOne(ctx context.Context, one *Simple) error
	GetMulti(ctx context.Context) (*Simple, *Simple, *Simple, error)
	SendMulti(ctx context.Context, one *Simple, two *Simple, three *Simple) error
	GetComplex(ctx context.Context) (*Complex, error)
	SendComplex(ctx context.Context, complex *Complex) error
	// added in v0.11.0
	GetSchemaError(ctx context.Context, code int) error
}

type TestApiClient added in v0.15.1

type TestApiClient interface {
	GetEmpty(ctx context.Context) error
	GetError(ctx context.Context) error
	GetOne(ctx context.Context) (*Simple, error)
	SendOne(ctx context.Context, one *Simple) error
	GetMulti(ctx context.Context) (*Simple, *Simple, *Simple, error)
	SendMulti(ctx context.Context, one *Simple, two *Simple, three *Simple) error
	GetComplex(ctx context.Context) (*Complex, error)
	SendComplex(ctx context.Context, complex *Complex) error
	// added in v0.11.0
	GetSchemaError(ctx context.Context, code int) error
}

type TestServer added in v0.10.0

type TestServer struct{}

func (*TestServer) GetComplex added in v0.10.0

func (c *TestServer) GetComplex(ctx context.Context) (*Complex, error)

func (*TestServer) GetEmpty added in v0.10.0

func (c *TestServer) GetEmpty(ctx context.Context) error

func (*TestServer) GetError added in v0.10.0

func (c *TestServer) GetError(ctx context.Context) error

func (*TestServer) GetMulti added in v0.10.0

func (c *TestServer) GetMulti(ctx context.Context) (*Simple, *Simple, *Simple, error)

func (*TestServer) GetOne added in v0.10.0

func (c *TestServer) GetOne(ctx context.Context) (*Simple, error)

func (*TestServer) GetSchemaError added in v0.11.0

func (c *TestServer) GetSchemaError(ctx context.Context, code int) error

func (*TestServer) SendComplex added in v0.10.0

func (c *TestServer) SendComplex(ctx context.Context, complex *Complex) error

func (*TestServer) SendMulti added in v0.10.0

func (c *TestServer) SendMulti(ctx context.Context, one, two, three *Simple) error

func (*TestServer) SendOne added in v0.10.0

func (c *TestServer) SendOne(ctx context.Context, one *Simple) error

type User

type User struct {
	ID       uint64 `json:"id" db:"id"`
	Username string `json:"USERNAME" db:"username"`
	Role     string `json:"role" db:"-"`
}

type WebRPCError added in v0.11.0

type WebRPCError struct {
	Name       string `json:"error"`
	Code       int    `json:"code"`
	Message    string `json:"msg"`
	Cause      string `json:"cause,omitempty"`
	HTTPStatus int    `json:"status"`
	// contains filtered or unexported fields
}

func ErrorWithCause deprecated added in v0.11.0

func ErrorWithCause(rpcErr WebRPCError, cause error) WebRPCError

Deprecated: Use .WithCause() method on WebRPCError.

func (WebRPCError) Error added in v0.11.0

func (e WebRPCError) Error() string

func (WebRPCError) Is added in v0.11.0

func (e WebRPCError) Is(target error) bool

func (WebRPCError) Unwrap added in v0.11.0

func (e WebRPCError) Unwrap() error

func (WebRPCError) WithCause added in v0.13.1

func (e WebRPCError) WithCause(cause error) WebRPCError

func (WebRPCError) WithCausef added in v0.18.3

func (e WebRPCError) WithCausef(format string, args ...interface{}) WebRPCError

type WebRPCServer

type WebRPCServer interface {
	http.Handler
}

Jump to

Keyboard shortcuts

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