apiHandler

package module
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: AGPL-3.0 Imports: 15 Imported by: 1

README

apiHandler-go

Usage

  • How to import?
go get -u github.com/Cellularhacker/apiHandler-go

※ Important

  • package name is just apiHandler. so you have to use like apiHandler.APIHandler, not apiHandler-go.APIHandler.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoffeeGET

func CoffeeGET(w http.ResponseWriter, _ *http.Request) *apiError.Error

func CreateTestPOST

func CreateTestPOST(w http.ResponseWriter, _ *http.Request) *apiError.Error

func ErrorHandler

func ErrorHandler(w http.ResponseWriter, r *http.Request, err *apiError.Error)

ErrorHandler returns a httprouter handler

func ExtractCSVData

func ExtractCSVData(v interface{}) string

func ExtractCSVHeaders

func ExtractCSVHeaders(v interface{}) string

func Handle added in v1.1.3

func Handle(handler APIHandler) http.HandlerFunc

func Info

func JSONHandler

func JSONHandler(w http.ResponseWriter, r *http.Request, data interface{}, pi *pageInfo.Response, code int)

func OKTestPOST

func OKTestPOST(w http.ResponseWriter, _ *http.Request) *apiError.Error

func Ping

func SendCSVResponse

func SendCSVResponse(w http.ResponseWriter, fileNamePrefix string, csv *bytes.Buffer) *apiError.Error

func SendCSVResponseFromString

func SendCSVResponseFromString(w http.ResponseWriter, fileNamePrefix string, csvStr *string) *apiError.Error

func SendCSVResponseWithFileName

func SendCSVResponseWithFileName(w http.ResponseWriter, fileName string, csvStr *string) *apiError.Error

func SendDataResponse

func SendDataResponse(w http.ResponseWriter, data interface{}, pi *pageInfo.Response, code int) *apiError.Error

func SendErrCodeResponse

func SendErrCodeResponse(w http.ResponseWriter, customCode, code int) *apiError.Error

func SendHTMLResponse

func SendHTMLResponse(w http.ResponseWriter, body []byte) *apiError.Error

func SendJSONResponse

func SendJSONResponse(w http.ResponseWriter, body interface{}) *apiError.Error

func SendMsgResponse

func SendMsgResponse(w http.ResponseWriter, msg string, code int) *apiError.Error

func SendNoContent

func SendNoContent(w http.ResponseWriter) *apiError.Error

func SendRedirectResponse

func SendRedirectResponse(w http.ResponseWriter, location string, statusCode int) *apiError.Error

func SendSuccessResponse

func SendSuccessResponse(w http.ResponseWriter, isCreate bool) *apiError.Error

Types

type APIHandler

type APIHandler func(http.ResponseWriter, *http.Request) *apiError.Error

APIHandler a string making it easy to handle errors

func (APIHandler) Handle

func (h APIHandler) Handle() http.HandlerFunc

Handle returns a httprouter handler

type DResponse

type DResponse struct {
	Code    int         `json:"code"`
	Success bool        `json:"success"`
	Data    interface{} `json:"data"`
}

type ErrorResp

type ErrorResp struct {
	Message string `json:"message"`
	Success bool   `json:"success"`
	Code    int    `json:"code"`
}

type InfoResp

type InfoResp struct {
	ServerTimeUnix int64  `json:"server_time"`
	TimeZone       string `json:"time_zone"`
}

type MResponse

type MResponse struct {
	Code    int    `json:"code"`
	Success bool   `json:"success"`
	Message string `json:"message,omitempty"`
}

type Response

type Response struct {
	Code       int                `json:"code"`
	Message    string             `json:"message,omitempty"`
	Success    bool               `json:"success"`
	PagingInfo *pageInfo.Response `json:"paging_info,omitempty"`
	Data       *interface{}       `json:"data,omitempty"`
}

type SResponse

type SResponse struct {
	Code    int         `json:"code"`
	Message string      `json:"message,omitempty"`
	Data    interface{} `json:"data"`
}

Directories

Path Synopsis
gin module

Jump to

Keyboard shortcuts

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