gores: github.com/alioygur/gores Index | Files

package gores

import "github.com/alioygur/gores"

Package gores http response utility library for GO

Index

Package Files

gores.go

Constants

const (
    CONNECT = "CONNECT"
    DELETE  = "DELETE"
    GET     = "GET"
    HEAD    = "HEAD"
    OPTIONS = "OPTIONS"
    PATCH   = "PATCH"
    POST    = "POST"
    PUT     = "PUT"
    TRACE   = "TRACE"
)

HTTP Methods

const (
    ApplicationJSON                  = "application/json"
    ApplicationJSONCharsetUTF8       = ApplicationJSON + "; " + CharsetUTF8
    ApplicationJavaScript            = "application/javascript"
    ApplicationJavaScriptCharsetUTF8 = ApplicationJavaScript + "; " + CharsetUTF8
    ApplicationXML                   = "application/xml"
    ApplicationXMLCharsetUTF8        = ApplicationXML + "; " + CharsetUTF8
    ApplicationForm                  = "application/x-www-form-urlencoded"
    ApplicationProtobuf              = "application/protobuf"
    ApplicationMsgpack               = "application/msgpack"
    TextHTML                         = "text/html"
    TextHTMLCharsetUTF8              = TextHTML + "; " + CharsetUTF8
    TextPlain                        = "text/plain"
    TextPlainCharsetUTF8             = TextPlain + "; " + CharsetUTF8
    MultipartForm                    = "multipart/form-data"
)

Media Types

const (
    AcceptEncoding     = "Accept-Encoding"
    Authorization      = "Authorization"
    ContentDisposition = "Content-Disposition"
    ContentEncoding    = "Content-Encoding"
    ContentLength      = "Content-Length"
    ContentType        = "Content-Type"
    Location           = "Location"
    Upgrade            = "Upgrade"
    Vary               = "Vary"
    WWWAuthenticate    = "WWW-Authenticate"
    XForwardedFor      = "X-Forwarded-For"
    XRealIP            = "X-Real-IP"
)

Headers

const (
    // CharsetUTF8 utf8 character set
    CharsetUTF8 = "charset=utf-8"

    // WebSocket web socket protocol
    WebSocket = "websocket"
)

func Download Uses

func Download(w http.ResponseWriter, r *http.Request, path string, name string) error

Download the client is prompted to save the file with provided `name`, name can be empty, in that case name of the file is used.

func Error Uses

func Error(w http.ResponseWriter, code int, message string)

Error sends a error response with a status code

func File Uses

func File(w http.ResponseWriter, r *http.Request, path string) error

File sends a response with the content of the file

func HTML Uses

func HTML(w http.ResponseWriter, code int, html string)

HTML sends an HTTP response with status code.

func JSON Uses

func JSON(w http.ResponseWriter, code int, i interface{}) error

JSON sends a JSON response with status code.

func JSONIndent Uses

func JSONIndent(w http.ResponseWriter, code int, i interface{}, prefix string, indent string) error

JSONIndent sends a JSON response with status code, but it applies prefix and indent to format the output.

func JSONP Uses

func JSONP(w http.ResponseWriter, code int, callback string, i interface{}) error

JSONP sends a JSONP response with status code. It uses `callback` to construct the JSONP payload.

func MustDownload Uses

func MustDownload(w http.ResponseWriter, r *http.Request, path string, name string)

MustDownload calls Download and panics on error

func MustFile Uses

func MustFile(w http.ResponseWriter, r *http.Request, path string)

MustFile calls File and panics on error

func MustJSON Uses

func MustJSON(w http.ResponseWriter, code int, i interface{})

MustJSON calls JSON and panics on error

func MustJSONIndent Uses

func MustJSONIndent(w http.ResponseWriter, code int, i interface{}, prefix string, indent string)

MustJSONIndent calls JSONIndent and panics on error

func MustJSONP Uses

func MustJSONP(w http.ResponseWriter, code int, callback string, i interface{})

MustJSONP calls JSONP and panics on error

func MustXML Uses

func MustXML(w http.ResponseWriter, code int, i interface{})

MustXML calls XML and panics on error

func MustXMLIndent Uses

func MustXMLIndent(w http.ResponseWriter, code int, i interface{}, prefix string, indent string)

MustXMLIndent calls XMLIndent and panics on error

func NoContent Uses

func NoContent(w http.ResponseWriter)

NoContent sends a response with no body and a status code.

func String Uses

func String(w http.ResponseWriter, code int, s string)

String sends a string response with status code.

func XML Uses

func XML(w http.ResponseWriter, code int, i interface{}) error

XML sends an XML response with status code.

func XMLIndent Uses

func XMLIndent(w http.ResponseWriter, code int, i interface{}, prefix string, indent string) error

XMLIndent sends an XML response with status code, but it applies prefix and indent to format the output.

Package gores imports 4 packages (graph) and is imported by 1 packages. Updated 2020-05-23. Refresh now. Tools for package owners.