api

package
v0.2.23 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 32 Imported by: 4

Documentation

Overview

Documentation of Web API.

Schemes: https, http
BasePath: /
Version: 1.0.0

Consumes:
- application/json

Produces:
- application/json

SecurityDefinitions:
basicAuth:
  type: basic

swagger:meta

Index

Constants

View Source
const (
	ErrCodeInvalid          = 40001
	ErrCodeDup              = 40002
	ErrCodeFailed           = 40003
	ErrCodeNotFound         = 40004
	ErrCodeSaveConfigFailed = 40005
)

Variables

View Source
var (
	ErrInvalid  = &Error{statusCode: http.StatusBadRequest, Code: 40001, Msg: "object invalid"}
	ErrDup      = &Error{statusCode: http.StatusBadRequest, Code: 40002, Msg: "object duplicated"}
	ErrCreate   = &Error{statusCode: http.StatusConflict, Code: 40003, Msg: "object creation failed"}
	ErrNotFound = &Error{statusCode: http.StatusBadRequest, Code: 40004, Msg: "object not found"}
	ErrSave     = &Error{statusCode: http.StatusInternalServerError, Code: 40005, Msg: "save config failed"}
)

Functions

func NewError

func NewError(status, code int, msg string) error

func NewService

func NewService(network, addr string, opts ...Option) (service.Service, error)

Types

type ErrCode

type ErrCode int

type Error

type Error struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	// contains filtered or unexported fields
}

Error is an api error.

func (*Error) Error

func (e *Error) Error() string

type Option

type Option func(*options)

func AccessLogOption

func AccessLogOption(enable bool) Option

func AutherOption

func AutherOption(auther auth.Authenticator) Option

func PathPrefixOption

func PathPrefixOption(pathPrefix string) Option

type Response

type Response struct {
	Code int    `json:"code,omitempty"`
	Msg  string `json:"msg,omitempty"`
}

Jump to

Keyboard shortcuts

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