Documentation
¶
Index ¶
- Variables
- func HTTPLogger(inner http.Handler, name string) http.Handler
- func NewRouter(serverAddress string, dbFile string) *mux.Router
- type AliasInfo
- type ColInfo
- type ErrStruct
- type Handlers
- func (h *Handlers) ActionAdd(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) ActionDel(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) ActionLookup(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) ActionRevLookup(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) ActionUpdate(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) ActionView(w http.ResponseWriter, r *http.Request)
- func (h *Handlers) Redirect(w http.ResponseWriter, r *http.Request)
- type RevLookupResponse
- type Row
- type RowInfo
- type StorageInterface
- func (s *StorageInterface) AddAlias(orig string, alias string, secret string) string
- func (s *StorageInterface) DelAlias(alias string, secret string) string
- func (s *StorageInterface) GetAllAliases(secret string) []AliasInfo
- func (s *StorageInterface) GetShortUrls(secret string, orig string) []string
- func (s *StorageInterface) URLFromAlias(alias string) *string
- func (s *StorageInterface) URLFromAliasTemplate(expandedTemplate string) *string
- func (s *StorageInterface) UpdateAlias(presAlias, oldVal, newVal, colname, secret string) string
- type ViewResponse
Constants ¶
This section is empty.
Variables ¶
var Log *logrus.Logger = newLogger()
Log is the logging object used by the binary.
Functions ¶
func HTTPLogger ¶
HTTPLogger returns a http.Handler that logs the http request.
Types ¶
type ColInfo ¶
type ColInfo struct { Name string `json:"name"` Label string `json:"label"` Datatype string `json:"datatype"` Bar bool `json:"bar"` Editable bool `json:"editable"` Values *string `json:"values"` }
ColInfo holds metadata for columns in the alias table showed in the UI.
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers struct has methods to handle http requests to be served by the webserver.
func (*Handlers) ActionAdd ¶
func (h *Handlers) ActionAdd(w http.ResponseWriter, r *http.Request)
ActionAdd handles http request to add a new bookmark.
func (*Handlers) ActionDel ¶
func (h *Handlers) ActionDel(w http.ResponseWriter, r *http.Request)
ActionDel handles http request to add a delete bookmark.
func (*Handlers) ActionLookup ¶
func (h *Handlers) ActionLookup(w http.ResponseWriter, r *http.Request)
ActionLookup handles http request to convert short url to the full url.
func (*Handlers) ActionRevLookup ¶
func (h *Handlers) ActionRevLookup(w http.ResponseWriter, r *http.Request)
ActionRevLookup handles http request to convert full url to the short url.
func (*Handlers) ActionUpdate ¶
func (h *Handlers) ActionUpdate(w http.ResponseWriter, r *http.Request)
ActionUpdate handles http request to add a update bookmark.
func (*Handlers) ActionView ¶
func (h *Handlers) ActionView(w http.ResponseWriter, r *http.Request)
ActionView handles http request to view bookmarks list.
type RevLookupResponse ¶
type RevLookupResponse struct {
ShortUrls []string `json:"shorturls"`
}
RevLookupResponse is response for RevLookup call.
type RowInfo ¶
type RowInfo struct { Fullurl string `json:"fullurl"` Alias string `json:"alias"` Shorturl string `json:"shorturl"` Action string `json:"action"` }
RowInfo contains information for a singe alias row in the alias table.
type StorageInterface ¶
type StorageInterface struct {
// contains filtered or unexported fields
}
StorageInterface is the interface to interact with the "storage layer" (i.e sqlite)
func NewStorageInterface ¶
func NewStorageInterface(dbFile string) *StorageInterface
NewStorageInterface creates and initializes a new storage interface object.
func (*StorageInterface) AddAlias ¶
func (s *StorageInterface) AddAlias( orig string, alias string, secret string) string
AddAlias adds an `alias` for `orig` url. Returns "ok" on success.
func (*StorageInterface) DelAlias ¶
func (s *StorageInterface) DelAlias(alias string, secret string) string
DelAlias deletes the given `alias`. Returns "ok" on success.
func (*StorageInterface) GetAllAliases ¶
func (s *StorageInterface) GetAllAliases(secret string) []AliasInfo
GetAllAliases gets all aliases. If the given secret matches the secret stored in db, then returns secret aliases as well.
func (*StorageInterface) GetShortUrls ¶
func (s *StorageInterface) GetShortUrls(secret string, orig string) []string
GetShortUrls gets the short urls for the given full url. If secret matches the secret in db, then returns secret aliases as well.
func (*StorageInterface) URLFromAlias ¶
func (s *StorageInterface) URLFromAlias(alias string) *string
URLFromAlias returns the full url for the given `alias`.
func (*StorageInterface) URLFromAliasTemplate ¶
func (s *StorageInterface) URLFromAliasTemplate(expandedTemplate string) *string
func (*StorageInterface) UpdateAlias ¶
func (s *StorageInterface) UpdateAlias( presAlias, oldVal, newVal, colname, secret string) string
UpdateAlias updates the alias for the given long url. Returns "ok" on success.
type ViewResponse ¶
ViewResponse is response for View call.
func CreateViewResponse ¶
func CreateViewResponse(aliases []AliasInfo, serverPrefix string) ViewResponse
CreateViewResponse creates viewResponse from the given aliases.