restapi

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const BadRequestPrefix string = "Bad Request"
View Source
const InternalServerErrorPrefix string = "Internal Server Error"
View Source
const NotFoundPrefix string = "404 Not Found"
View Source
const NotImplementedPrefix string = "Not Implemented"
View Source
const UnprocessablePrefix string = "Unprocessable Entity"

Variables

This section is empty.

Functions

func ExtractLimitAndOffset

func ExtractLimitAndOffset(qs url.Values) (int, int, error)

ExtractLimitAndOffset is a convience method to extract pagination and limit values passed to a handler that supports pages.

Types

type DataResponse

type DataResponse struct {
	Code int         `json:"code"`
	Data interface{} `json:"data"`
}

type ErrorHandler

type ErrorHandler struct{}

func (*ErrorHandler) Write

func (t *ErrorHandler) Write(rw http.ResponseWriter, err error, statusCode int)

type ErrorResponder

type ErrorResponder interface {
	Write(rw http.ResponseWriter, err error, statusCode int)
}

type RESTAPIHandler

type RESTAPIHandler interface {
	GetHttpHandler(mountPath string) http.Handler
}

type Responder

type Responder interface {
	Write(rw http.ResponseWriter, data interface{}, statusCode int)
	WriteRaw(rw http.ResponseWriter, data interface{}, statusCode int)
	Redirect(rw http.ResponseWriter, r *http.Request, uri string)
}

type ResponseHandler

type ResponseHandler struct{}

func (*ResponseHandler) Redirect

func (t *ResponseHandler) Redirect(rw http.ResponseWriter, r *http.Request, uri string)

func (*ResponseHandler) Write

func (t *ResponseHandler) Write(rw http.ResponseWriter, data interface{}, statusCode int)

func (*ResponseHandler) WriteRaw

func (t *ResponseHandler) WriteRaw(rw http.ResponseWriter, data interface{}, statusCode int)

type ServerResponse

type ServerResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Directories

Path Synopsis
modules
v1

Jump to

Keyboard shortcuts

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