Make things pretty

This commit is contained in:
2016-07-18 01:27:22 +01:00
parent c53b088f19
commit 10873ae9ae
12 changed files with 312 additions and 178 deletions

View File

@@ -6,14 +6,18 @@ import (
"github.com/qiangxue/fasthttp-routing"
)
func makeURLResponse(c *routing.Context, uid []byte, url []byte) URLResponse {
return URLResponse{
func makeResponse(c *routing.Context, uid []byte, url []byte) Response {
return Response{
UID: string(uid),
URL: makeShortURL(c, uid),
Target: string(url),
}
}
func makeErrResponse(err error) Response {
return Response{Error: err.Error()}
}
func makeShortURL(c *routing.Context, uid []byte) string {
shortURL := &url.URL{
Scheme: "http",