web

package
v0.0.0-...-3775a0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2017 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package web contains main web and API handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContext

func GetContext(ctx context.Context) (string, error)

GetContext reads path from context.

func HandleAPI

func HandleAPI(ctx context.Context, w http.ResponseWriter, r *http.Request) (int, error)

HandleAPI handles API request to get shor url.

func HandleHTML

func HandleHTML(ctx context.Context, w http.ResponseWriter, r *http.Request) (int, error)

HandleHTML returns an index HTML page.

func HandleRedirect

func HandleRedirect(ctx context.Context, w http.ResponseWriter, r *http.Request) (int, error)

HandleRedirect finds short URL and redirects a request.

func ResetTplCache

func ResetTplCache(cfg *conf.Cfg) error

ResetTplCache resets template cache.

func SetContext

func SetContext(ctx context.Context, path string) context.Context

SetContext writes path to context.

Types

type Response

type Response struct {
	URL   string `json:"url"`
	Short string `json:"short"`
}

Response is API response for URL shorting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL