Documentation ¶
Overview ¶
Extra functions for golang
Index ¶
- func AllHeaders(w *http.ResponseWriter)
- func AllMethods(w *http.ResponseWriter)
- func AllOrigin(w *http.ResponseWriter)
- func ApplicationJson(w *http.ResponseWriter)
- func Command(name string, arg ...string) error
- func ComparePasswordHash(password string, hash string) error
- func DeleteRequest(url, token string, body []byte) (*http.Response, error)
- func FloatAppend(slice []float64, addon float64) []float64
- func IntAppend(slice []int64, addon int64) []int64
- func IsLinux() bool
- func IsOSX() bool
- func IsWASM() bool
- func IsWindows() bool
- func PostRequest(url, token string, body []byte) (*http.Response, error)
- func PutRequest(url, token string, body []byte) (*http.Response, error)
- func ReadJSONFile(name string, v interface{}) (content string, err error)
- func StringAppend(slice []string, addon string) []string
- type Route
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllHeaders ¶
func AllHeaders(w *http.ResponseWriter)
AllHeaders es equivalente a "Access-Control-Allow-Headers: *"
func AllMethods ¶
func AllMethods(w *http.ResponseWriter)
AllMethods es equivalente a "Access-Control-Allow-Methods: *"
func AllOrigin ¶
func AllOrigin(w *http.ResponseWriter)
AllOrigin es equivalente a "Access-Control-Allow-Origin: *"
func ApplicationJson ¶
func ApplicationJson(w *http.ResponseWriter)
ApplicationJson es equivalente a "Content-Type: application/json; charset=utf-8*"
func ComparePasswordHash ¶
ComparePasswordHash verifica los una contraseña en string y un hash en string, devuelve un error si estos no coinciden.
func DeleteRequest ¶
WARNING: Esta función permite conectarse a dominios con certificado autofirmado. Utilizar solo en dominios de confianza.
DeleteRequest realiza una request con el método PUT con autorización tipo Bearer token.
EXAMPLE:
body := struct { ID string `json:"id"` }{ ID: "MyElementID" } data, _ := json.Marshal(body) response, err := DeleteRequest("https://example.com", "my.awesome.Token", data)
func FloatAppend ¶
FloatAppend permite insertar un float64 a un slice tras comprobar que es mayor que 0
func PostRequest ¶
WARNING: Esta función permite conectarse a dominios con certificado autofirmado. Utilizar solo en dominios de confianza.
PostRequest realiza una request con el método POST con autorización tipo Bearer token.
EXAMPLE:
body := struct { Message string `json:"message"` }{ Message: "Hola Mundo" } data, _ := json.Marshal(body) response, err := PostRequest("https://example.com", "my.awesome.Token", data)
func PutRequest ¶
WARNING: Esta función permite conectarse a dominios con certificado autofirmado. Utilizar solo en dominios de confianza.
PutRequest realiza una request con el método PUT con autorización tipo Bearer token.
EXAMPLE:
body := struct { Message string `json:"message"` }{ Message: "Hola Mundo" } data, _ := json.Marshal(body) response, err := PutRequest("https://example.com", "my.awesome.Token", data)
func ReadJSONFile ¶
Lee un archivo tipo JSON, de la ubicación indicada en el parámetro name, e intenta convertirlo a un struct. , retorna el contenido del archivo ─de encontrarlo─ y un error.
func StringAppend ¶
StringAppend permite insertar un string a slice tras comprobar si existe una entrada similar.