Documentation ¶
Index ¶
- Constants
- Variables
- func Base64ToImg(w io.Writer, base string) (string, error)
- func BindBody(r *http.Request, i interface{}) 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 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 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 GetIdxContentType(s ContentType) string
- func GetRootSchema(graphql embed.FS, dir string) (string, error)
- func Graph(endpoint string) http.HandlerFunc
- func Graphql(graphql embed.FS, dir string, resolver interface{}, opts ...graph.SchemaOpt) http.HandlerFunc
- func HandlerAdapter(a Adapter) http.HandlerFunc
- func HttpTracer(next http.Handler) http.Handler
- func ImgToBase64(r io.ReadCloser) (string, error)
- func JSONResponse(w http.ResponseWriter)
- func Redirect(w http.ResponseWriter, r *http.Request, url string)
- func RenderReader(r *http.Request) interface{}
- func RenderWriter(r *http.Request, value interface{})
- func RequestJSONBody(r *http.Request, extract interface{}) error
- func ResponseCSVPayload(w http.ResponseWriter, code int, rows [][]string, filename string) error
- func ResponseJSONPayload(w http.ResponseWriter, r *http.Request, code int, responses ...interface{}) error
- func SemanticVersion(r *http.Request, label string, version string)
- func SetContentType(contentType ContentType) func(next http.Handler) http.Handler
- func ToDelimited(s string, delimiter uint8) string
- func ToScreamingDelimited(s string, delimiter uint8, ignore string, screaming bool) string
- func Transport(tlsInsecure bool, timeout int) http.Client
- func Welkommen() string
- type Adapter
- type ContentType
- type GRPCCallback
- type GRPCOpts
- type GRPCPort
- type GRpc
- type Https
- type Meta
- type Pagination
- type Response
- type ServeOpts
- type Server
- type Version
- type WebPort
- type WebTimeOut
Constants ¶
const ( HeaderAuthorization = "Authorization" HeaderContentDisposition = "Content-Disposition" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderCookie = "Cookie" HeaderXCSRFToken = "X-CSRF-Token" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderXTraceId = "X-Trace-Id" HeaderUberTraceId = "Uber-Trace-Id" )
const ( MIMEApplicationJSON = "application/json" MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + charsetUTF8 MIMEApplicationJavaScript = "application/javascript" MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + charsetUTF8 MIMEApplicationXML = "application/xml" MIMEApplicationXMLCharsetUTF8 = MIMEApplicationXML + "; " + charsetUTF8 MIMETextXML = "text/xml" MIMETextXMLCharsetUTF8 = MIMETextXML + "; " + charsetUTF8 MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEApplicationProtobuf = "application/protobuf" MIMEApplicationMsgpack = "application/msgpack" MIMETextCSV = "text/csv" MIMETextCSVCharsetUTF8 = MIMETextCSV + "; " + charsetUTF8 MIMETextHTML = "text/html" MIMETextHTMLCharsetUTF8 = MIMETextHTML + "; " + charsetUTF8 MIMETextPlain = "text/plain" MIMETextPlainCharsetUTF8 = MIMETextPlain + "; " + charsetUTF8 MIMEMultipartForm = "multipart/form-data" MIMEOctetStream = "application/octet-stream" MIMEImageJPEG = "image/jpeg" MIMEImagePNG = "image/png" )
MIME types
const ( ContentTypeUnknown = iota ContentTypePlainText ContentTypeHTML ContentTypeJSON ContentTypeXML ContentTypeForm ContentTypeMultipartForm ContentTypeEventStream )
ContentTypes handled by this package.
Variables ¶
var ( CtxResponse = ctxKeyResponse{Name: "context Respond"} CtxVersion = ctxKeyVersion{Name: "context version"} )
var (
ContentTypeCtxKey = &ctxRender{HeaderContentType}
)
var CtxError = ctxError{Name: "context error"}
var (
RenderContext = ctxRender{Name: "context render"}
)
var TracerContext = tracerContext{Name: "context Respond"}
Functions ¶
func ErrBadGateway ¶ added in v0.2.0
ErrBadGateway error http StatusBadGateway
func ErrBadRequest ¶ added in v0.2.0
ErrBadRequest error http StatusBadRequest
func ErrForbidden ¶ added in v0.2.0
ErrForbidden error http StatusForbidden
func ErrGatewayTimeout ¶ added in v0.2.0
ErrGatewayTimeout error http StatusGatewayTimeout
func ErrInternalServerError ¶ added in v0.2.0
ErrInternalServerError error http StatusInternalServerError
func ErrMethodNotAllowed ¶ added in v0.2.0
ErrMethodNotAllowed error http StatusMethodNotAllowed
func ErrNotAcceptable ¶ added in v0.2.0
ErrNotAcceptable error http StatusNotAcceptable
func ErrPaymentRequired ¶ added in v0.2.0
ErrPaymentRequired error http StatusPaymentRequired
func ErrProxyAuthRequired ¶ added in v0.2.0
ErrProxyAuthRequired error http StatusProxyAuthRequired
func ErrRequestTimeout ¶ added in v0.2.0
ErrRequestTimeout error http StatusRequestTimeout
func ErrServiceUnavailable ¶ added in v0.2.0
ErrServiceUnavailable error http StatusServiceUnavailable
func ErrUnauthorized ¶ added in v0.2.0
ErrUnauthorized error http StatusUnauthorized
func ErrUnprocessableEntity ¶ added in v0.2.0
ErrUnprocessableEntity error http StatusUnprocessableEntity
func ErrUnsupportedMediaType ¶ added in v0.2.0
ErrUnsupportedMediaType error http StatusUnsupportedMediaType
func GetIdxContentType ¶ added in v0.2.6
func GetIdxContentType(s ContentType) string
GetIdxContentType is a middleware that forces response Content-Type.
func Graphql ¶
func Graphql(graphql embed.FS, dir string, resolver interface{}, opts ...graph.SchemaOpt) http.HandlerFunc
Graphql handler func
func HandlerAdapter ¶ added in v0.2.0
func HandlerAdapter(a Adapter) http.HandlerFunc
func ImgToBase64 ¶ added in v0.2.6
func ImgToBase64(r io.ReadCloser) (string, error)
func JSONResponse ¶ added in v0.2.0
func JSONResponse(w http.ResponseWriter)
JSONResponse set header content-type to json format
func RenderReader ¶ added in v0.1.9
func RenderWriter ¶ added in v0.1.9
func RequestJSONBody ¶ added in v0.2.0
RequestJSONBody get json body format
func ResponseCSVPayload ¶ added in v0.2.0
ResponseCSVPayload set csv payload for response http
func ResponseJSONPayload ¶ added in v0.3.0
func ResponseJSONPayload(w http.ResponseWriter, r *http.Request, code int, responses ...interface{}) error
ResponseJSONPayload set payload for response http
func SetContentType ¶ added in v0.2.6
func SetContentType(contentType ContentType) func(next http.Handler) http.Handler
SetContentType is a middleware that forces response Content-Type.
func ToDelimited ¶ added in v0.3.1
ToDelimited converts a string to delimited.snake.case (in this case `delimiter = '.'`)
func ToScreamingDelimited ¶ added in v0.3.1
ToScreamingDelimited converts a string to SCREAMING.DELIMITED.SNAKE.CASE (in this case `delimiter = '.'; screaming = true`) or delimited.snake.case (in this case `delimiter = '.'; screaming = false`)
Types ¶
type ContentType ¶ added in v0.2.6
type ContentType int
ContentType is an enumeration of common HTTP content types.
func GetContentType ¶ added in v0.2.6
func GetContentType(s string) ContentType
GetContentType is a middleware that forces response Content-Type.
func GetRequestContentType ¶ added in v0.2.6
func GetRequestContentType(r *http.Request) ContentType
GetRequestContentType is a helper function that returns ContentType based on context or request headers.
type GRPCCallback ¶
type GRPCOpts ¶
type GRPCOpts struct { Port GRPCPort Opts []rpc.ServerOption }
type GRpc ¶
type GRpc struct { Port GRPCPort Opts []rpc.ServerOption // contains filtered or unexported fields }
func NewServerGRPC ¶
func (*GRpc) Run ¶
func (g *GRpc) Run(callback GRPCCallback) error
type Pagination ¶ added in v0.3.0
type Pagination struct { Limit int `json:"limit"` NextCursor interface{} `json:"next_cursor"` }
func (Pagination) GetLimit ¶ added in v0.3.0
func (p Pagination) GetLimit() int
type Response ¶
type Response struct { Version interface{} `json:"version,omitempty"` Meta interface{} `json:"meta,omitempty"` Data interface{} `json:"data,omitempty"` Pagination interface{} `json:"pagination,omitempty"` }
type ServeOpts ¶
type ServeOpts struct { Port WebPort TimeOut WebTimeOut TLS Https CertFile string KeyFile string }
type Server ¶
type Server struct { Port WebPort TimeOut WebTimeOut TLS Https CertFile string KeyFile string // contains filtered or unexported fields }
func NewServerMux ¶
type WebTimeOut ¶
type WebTimeOut int