restserver

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxBufferSize int64 = 1024 * 1024
)
View Source
const INDEX = "index.html"

Variables

View Source
var (
	ErrInvalidRequestParameter = NewError(int(reqParamErr), "Invalid request parameter", "")
	ErrInvalidRequestBody      = NewError(int(reqBodyErr), "Invalid request body", "")
)
View Source
var (
	ErrInvalidWhence    = errors.New("invalid whence")
	ErrNegativePosition = errors.New("negative position")
	ErrMaxSizeExceeded  = errors.New("max size exceeded")
)

Functions

func New

func New(opts ...Option) *gin.Engine

New is *gin.Engine

Endpoints base is `/api/v1/`

• /permissions

• /roles

• /organizations

• /users

func Render

func Render(c *gin.Context, code int, obj protoiface.MessageV1)

func WithDebug

func WithDebug(conf *config)

func WriteJSON

func WriteJSON(w http.ResponseWriter, obj protoiface.MessageV1) error

Types

type Error

type Error struct {
	Code        int    `json:"code"`
	Message     string `json:"message"`
	Description string `json:"description"`
}

func NewError

func NewError(code int, message, description string) *Error

func (*Error) Copy

func (e *Error) Copy() Error

func (*Error) Error

func (e *Error) Error() string

type JSON

type JSON struct {
	Data protoiface.MessageV1
}

func (JSON) Render

func (r JSON) Render(w http.ResponseWriter) (err error)

func (JSON) WriteContentType

func (r JSON) WriteContentType(w http.ResponseWriter)

type Option

type Option func(conf *config)

func WithUI

func WithUI(enabled bool, prefix, root string, indexes bool, baseURL string) Option

func WithWhiteList

func WithWhiteList(whitelistIp string) Option

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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