Documentation
¶
Overview ¶
The shrt module implements a simple (perhaps simplistic) URL shortener. It also handles go-get requests. See the cmd/shrt package documentation for a fuller explanation of the server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ShrtFile ¶
type ShrtFile struct {
// contains filtered or unexported fields
}
The ShrtFile struct contains the data read from a specially-formatted file. The syntax of the file is human readable. Each line represents a key-value pair. The key is everything to the left of the first equals sign, and the value is everything to the right. Whitespace is trimmed from the beginning and end of both keys and values.
func NewShrtFile ¶
The NewShrtFile function creates a new ShrtFile. The filesystem is checked for the existence of a node at the specified path, and the NewShrtFile returns an error if something is there. This constitutes a weak check, since a file could easily be created before Write() is called, in which case the existing file will be truncated.
func ReadShrtFile ¶
The ReadShrtFile function reads an existing ShrtFile from the filesystem and returns a pointer to a ShrtFile object. See the ShrtFile documentation for the expected file format.
func (*ShrtFile) Get ¶
The Get method gets the value of the specified key. If the key does not exist, an empty string is returned.
func (*ShrtFile) Put ¶
The Put method adds a the specified value, associating it with the specified key. The value is overwritten if the key already exists.