Documentation ¶
Index ¶
- Constants
- func AllMethods() []string
- func CheckResponseCode(expected, got int) error
- func CorsAllowAnythingMiddleware() func(http.Handler) http.Handler
- func CorsCustomMiddleware(config CustomCors) func(http.Handler) http.Handler
- func DecodeJSONDataResponse(reader io.Reader, dest interface{}) errorsx.Error
- func GetBodyOrErrorMsg(resp *http.Response) string
- func NewLocalDevServerProxy() (http.Handler, errorsx.Error)
- func NewServerWithTimeouts() *http.Server
- func RemoveGzip(resp *http.Response) (io.ReadCloser, error)
- type CustomCors
- type DataResponse
- type Doer
- type MockDoer
Constants ¶
const LocalDevServerEnvVarName = "LOCAL_DEV_SERVER_URL"
LocalDevServerEnvVarName is the environment variable name for the dev server For example the standard create-react-app webpack server, this value will be: "http://localhost:3000/" If using create-react-app, you can also add BROWSER=0 to the start of the npm/yarn "start" task, and that will prevent a browser tab being automatically opened.
Variables ¶
This section is empty.
Functions ¶
func AllMethods ¶
func AllMethods() []string
func CheckResponseCode ¶
func CorsAllowAnythingMiddleware ¶
CorsAllowAnythingMiddleware allows any request from anywhere
func CorsCustomMiddleware ¶
func CorsCustomMiddleware(config CustomCors) func(http.Handler) http.Handler
CorsAllowAnythingMiddleware allows any request from anywhere
func DecodeJSONDataResponse ¶
func GetBodyOrErrorMsg ¶
GetBodyOrErrorMsg returns the response body, or a string with the error message when getting the response body. It's useful for logging information, when receiving an error.
func NewLocalDevServerProxy ¶
NewLocalDevServerProxy creates a http handler to proxy a local dev server setup
func NewServerWithTimeouts ¶
NewServerWithTimeouts returns an http server with some sensible timeouts
func RemoveGzip ¶
func RemoveGzip(resp *http.Response) (io.ReadCloser, error)
Types ¶
type CustomCors ¶
type DataResponse ¶
type DataResponse struct {
Data interface{} `json:"data"`
}