README

HuperWebs

helpers

This module contains several helper-functions that should make building web applications with Golang easier.

GetExtension

GetExtension parses the given string, by taking everything before the optional question-mark (?), then taking everything after the last dot. If there is no extension in the filename, this function will return the entire filename (without parameters).

ExtractFilePath

ExtractFilePath extracts the path (directory), name (without extension) and extension. The parameters (after '?') are stripped entirely.

GetStringArray

GetStringArray allows easy parsing of context string-array values.

Expand ▾ Collapse ▴

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFilePath

func ExtractFilePath(url string) (string, string, string)

    ExtractFilePath goes from "https://aa.bb/abc/def.ghi?jkl=mnp&qrs=tuv" to ("abc/", "def", "ghi")

    func Filter

    func Filter(str string, search string) string

    func FormInteger

    func FormInteger(r *http.Request, name string) int

    func GetExtension

    func GetExtension(filename *string) string

      GetExtension goes from "https://aa.bb/abc/def.ghi?jkl=mnp&qrs=tuv" to "ghi"

      func GetStringArray

      func GetStringArray(r *http.Request, name string) []string

        GetStringArray tries to retrieve the context.Get(r, name) value as an []string

        func LastURLParameter

        func LastURLParameter(r *http.Request) string

          LastURLParameter treats everything after the last slash (up until the question mark) as parameter-value

          func MaxParallelism

          func MaxParallelism() int

            MaxParallelism runs the maximum number of goroutines that should be created

            func RemoveFromStringArray

            func RemoveFromStringArray(arr *[]string, elem string)

            func RemoveFromStringArrayIndex

            func RemoveFromStringArrayIndex(arr *[]string, elem int)

            func ToFriendly

            func ToFriendly(s string) string

              ToFriendly converts a string to a HTML-friendly version. Replaces &, /, and space. Trims dashes and slashes.

              Types

              type CacheObject

              type CacheObject struct {
              	// Expires is the expiration-interval after which the object should be fetched again
              	Expires time.Duration
              
              	// Fetch is the function that retrieves the value from the source
              	Fetch func() interface{}
              	// contains filtered or unexported fields
              }

              func NewCacheObject

              func NewCacheObject(exp time.Duration, f func() interface{}) CacheObject

              func (*CacheObject) Val

              func (o *CacheObject) Val() interface{}

                Val fetches the actual value from source using the Fetch function - only when needed.

                type CacheStorage

                type CacheStorage struct {
                	// contains filtered or unexported fields
                }

                func NewCacheStorage

                func NewCacheStorage(cacheDir string) *CacheStorage

                func (*CacheStorage) Add

                func (c *CacheStorage) Add(urlPath, requestUrl string)

                func (*CacheStorage) Delete

                func (c *CacheStorage) Delete(urlPath string)

                func (*CacheStorage) Exists

                func (c *CacheStorage) Exists(urlPath, requestUrl string) bool