Documentation ¶
Overview ¶
Package rest is port adapter via http/s protocol # This manifest was generated by ymir. DO NOT EDIT.
Package rest is port adapter via http/s protocol # This manifest was generated by ymir. DO NOT EDIT.
Package rest is port adapter via http/s protocol # This manifest was generated by ymir. DO NOT EDIT.
Package rest is port adapter via http/s protocol # This manifest was generated by ymir. DO NOT EDIT.
Package rest is port adapter via http/s protocol # This manifest was generated by ymir. DO NOT EDIT.
Package rest is port adapter via http/s protocol # This manifest was generated by ymir. DO NOT EDIT.
Package rest is port adapter via http/s protocol # This manifest was generated by ymir. DO NOT EDIT.
Package rest is port adapter via http/s protocol # This manifest was generated by ymir. DO NOT EDIT.
Package rest is port adapter via http/s protocol # This manifest was generated by ymir. DO NOT EDIT.
Package rest is port adapter via http/s protocol # This manifest was generated by ymir. DO NOT EDIT.
Package rest is port adapter via http/s protocol # This manifest was generated by ymir. DO NOT EDIT.
Index ¶
- Variables
- func DecodeForm(r *http.Request, v any) error
- func DecodeJSON(r io.Reader, v any) error
- func DecodeXML(r io.Reader, v any) error
- func ErrBadGateway(w http.ResponseWriter, r *http.Request, err error) error
- func ErrBadRequest(w http.ResponseWriter, r *http.Request, err error) error
- func ErrForbidden(w http.ResponseWriter, r *http.Request, err error) error
- func ErrGatewayTimeout(w http.ResponseWriter, r *http.Request, err error) error
- func ErrInternalServerError(w http.ResponseWriter, r *http.Request, err error) error
- func ErrMethodNotAllowed(w http.ResponseWriter, r *http.Request, err error) error
- func ErrNotAcceptable(w http.ResponseWriter, r *http.Request, err error) error
- func ErrNotFound(w http.ResponseWriter, r *http.Request, err error) error
- func ErrPaymentRequired(w http.ResponseWriter, r *http.Request, err error) error
- func ErrProxyAuthRequired(w http.ResponseWriter, r *http.Request, err error) error
- func ErrRequestTimeout(w http.ResponseWriter, r *http.Request, err error) error
- func ErrServiceUnavailable(w http.ResponseWriter, r *http.Request, err error) error
- func ErrStatusConflict(w http.ResponseWriter, r *http.Request, err error) error
- func ErrUnauthorized(w http.ResponseWriter, r *http.Request, err error) error
- func ErrUnprocessableEntity(w http.ResponseWriter, r *http.Request, err error) error
- func ErrUnsupportedMediaType(w http.ResponseWriter, r *http.Request, err error) error
- func GetBind[T any](r *http.Request) (T, error)
- func NotFoundDefault() http.HandlerFunc
- func Paging(r *http.Request, p Pagination)
- func SemanticVersion(label string, version string) func(next http.Handler) http.Handler
- func StatusAccepted(r *http.Request)
- func StatusCreated(r *http.Request)
- func StatusMovedPermanently(r *http.Request)
- type Adapter
- type Binder
- type ContentType
- type DefaultClientHttp
- type HeaderType
- type Meta
- type Option
- type Pagination
- type RequestConstraint
- type RequestNotFound
- type RequestType
- type Response
- type ResponseCSV
- type ResponseConstraint
- type ResponseNotFound
- type ResponseType
- type Server
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( // ErrServerNotStarted is define error when server not started. ErrServerNotStarted = errors.New("server not started") // ErrServerAlreadyStarted is define error when server already started. ErrServerAlreadyStarted = errors.New("server already started") // ErrServerHandlerNotProvided is define error when server handler not provided. ErrServerHandlerNotProvided = errors.New("server handler not provided") )
Functions ¶
func DecodeForm ¶
DecodeForm decodes a given reader into an interface using the form decoderBody.
func DecodeJSON ¶
DecodeJSON decodes a given reader into an interface using the json decoderBody.
func ErrBadGateway ¶
ErrBadGateway error http StatusBadGateway.
func ErrBadRequest ¶
ErrBadRequest error http StatusBadRequest.
func ErrForbidden ¶
ErrForbidden error http StatusForbidden.
func ErrGatewayTimeout ¶
ErrGatewayTimeout error http StatusGatewayTimeout.
func ErrInternalServerError ¶
ErrInternalServerError error http StatusInternalServerError.
func ErrMethodNotAllowed ¶
ErrMethodNotAllowed error http StatusMethodNotAllowed.
func ErrNotAcceptable ¶
ErrNotAcceptable error http StatusNotAcceptable.
func ErrNotFound ¶
ErrNotFound error http StatusNotFound.
func ErrPaymentRequired ¶
ErrPaymentRequired error http StatusPaymentRequired.
func ErrProxyAuthRequired ¶
ErrProxyAuthRequired error http StatusProxyAuthRequired.
func ErrRequestTimeout ¶
ErrRequestTimeout error http StatusRequestTimeout.
func ErrServiceUnavailable ¶
ErrServiceUnavailable error http StatusServiceUnavailable.
func ErrStatusConflict ¶
ErrStatusConflict error http StatusConflict.
func ErrUnauthorized ¶
ErrUnauthorized error http StatusUnauthorized.
func ErrUnprocessableEntity ¶
ErrUnprocessableEntity error http StatusUnprocessableEntity.
func ErrUnsupportedMediaType ¶
ErrUnsupportedMediaType error http StatusUnsupportedMediaType.
func NotFoundDefault ¶
func NotFoundDefault() http.HandlerFunc
NotFoundDefault sets a custom http.HandlerFunc for routing paths that could not be found. The default 404 handler is `http.NotFound`.
func SemanticVersion ¶
SemanticVersion is middleware handler to semantic versioning.
func StatusAccepted ¶
StatusAccepted error http StatusAccepted.
func StatusMovedPermanently ¶
StatusMovedPermanently error http StatusMovedPermanently.
Types ¶
type Adapter ¶
type Adapter[Request RequestConstraint, Response ResponseConstraint] func(w http.ResponseWriter, r *http.Request) (Response, error)
Adapter is wrapper func type for error handler.
type Binder ¶
type Binder[T any] struct { // contains filtered or unexported fields }
type ContentType ¶
type ContentType int
ContentType - Custom type to hold value for find and replace on content type.
const ( UnknownMedia ContentType = iota MIMEApplicationJSON MIMEApplicationJSONCharsetUTF8 MIMEApplicationJavaScript MIMEApplicationJavaScriptCharsetUTF8 MIMEApplicationXML MIMEApplicationXMLCharsetUTF8 MIMETextXML MIMETextXMLCharsetUTF8 MIMEApplicationForm MIMEApplicationProtobuf MIMEApplicationMsgpack MIMETextCSV MIMETextCSVCharsetUTF8 MIMETextHTML MIMETextHTMLCharsetUTF8 MIMETextPlain MIMETextPlainCharsetUTF8 MIMETextJavaScript MIMETextJavaScriptCharsetUTF8 MIMEMultipartForm MIMEOctetStream MIMEImageJPEG MIMEImagePNG )
Declare related constants for each ContentType starting with index 1.
func GetRequestContentType ¶
func GetRequestContentType(r *http.Request) ContentType
GetRequestContentType is a helper function that returns ContentType based on context or request headers.
func (ContentType) String ¶
func (m ContentType) String() string
String - Creating common behavior - give the type a String function.
type DefaultClientHttp ¶
type DefaultClientHttp struct { // BaseUrl is the base url to set on requests. BaseUrl *url.URL // Transport is the underlying HTTP transport. // If nil, http.DefaultTransport is used. Transport http.RoundTripper }
DefaultClientHttp is the default Client and is used by Get, Head, and Post.
type HeaderType ¶
type HeaderType int
HeaderType - Custom type to hold value for find and replace on header type.
const ( HeaderAuthorization HeaderType = iota HeaderContentDisposition HeaderContentEncoding HeaderContentLength HeaderContentType HeaderContentDesc HeaderCookie HeaderXCSRFToken HeaderAccessControlAllowOrigin HeaderXTraceId HeaderUberTraceId HeaderContentTypeOptions )
func (HeaderType) String ¶
func (h HeaderType) String() string
String - Creating common behavior - give the type a String function.
type Meta ¶
type Meta struct { Code string `json:"code,omitempty"` Message string `json:"error_message,omitempty"` }
Meta holds the response definition for the Meta entity.
type Option ¶
Option is server type return func.
func WithIdleTimeout ¶
WithIdleTimeout will assign to idle timeout field server.
func WithReadTimeout ¶
WithReadTimeout will assign to read field server.
func WithShutdownTimeout ¶
WithShutdownTimeout will assign to shut down timeout field server.
func WithWriteTimeout ¶
WithWriteTimeout will assign to write field server.
type Pagination ¶
type Pagination struct { Page int `json:"page,omitempty"` Limit int `json:"per_page,omitempty"` Size int `json:"page_count,omitempty"` Total int `json:"total_count,omitempty"` }
Pagination holds the response definition for the Pagination entity.
type RequestConstraint ¶
type RequestConstraint interface { any }
RequestConstraint is custom constraint type adapter request.
type RequestType ¶
type RequestType int
RequestType - Custom type to hold value for find and replace on context value request type.
const CtxPayloadRequest RequestType = iota
CtxPayloadRequest Declare related constants for each RequestType starting with index 1.
type Response ¶
type Response[W RequestConstraint, R ResponseConstraint] struct { Meta `json:"meta"` Version `json:"version"` Pagination `json:"pagination,omitempty"` Data any `json:"data,omitempty"` // contains filtered or unexported fields }
Response holds the response definition for the Response entity.
func HandlerAdapter ¶
func HandlerAdapter[RequestType RequestConstraint, ResponseType ResponseConstraint](a Adapter[RequestType, ResponseType]) *Response[RequestType, ResponseType]
HandlerAdapter is middleware handler to process error.
func (*Response[W, R]) CSV ¶
func (e *Response[W, R]) CSV(w http.ResponseWriter, r *http.Request)
CSV sends a CSV format response with status code.
type ResponseCSV ¶
ResponseCSV - Custom type to hold value from [][]string type to csv format response.
type ResponseConstraint ¶
type ResponseConstraint interface { any }
ResponseConstraint is custom constraint type adapter response.
type ResponseType ¶
type ResponseType int
ResponseType - Custom type to hold value for find and replace on context value response type.
const ( CtxPagination ResponseType = iota CtxVersion CtxStatusCode )
Declare related constants for each ResponseType starting with index 1.
func (ResponseType) String ¶
func (r ResponseType) String() string