mirror of
https://github.com/jimeh/ozu.io.git
synced 2026-02-19 08:06:39 +00:00
26 lines
450 B
Go
26 lines
450 B
Go
package web
|
|
|
|
import (
|
|
"net/url"
|
|
|
|
"github.com/qiangxue/fasthttp-routing"
|
|
)
|
|
|
|
func makeURLResponse(c *routing.Context, uid []byte, url []byte) URLResponse {
|
|
return URLResponse{
|
|
UID: string(uid),
|
|
URL: makeShortURL(c, uid),
|
|
Target: string(url),
|
|
}
|
|
}
|
|
|
|
func makeShortURL(c *routing.Context, uid []byte) string {
|
|
shortURL := &url.URL{
|
|
Scheme: "http",
|
|
Host: string(c.Host()),
|
|
Path: "/" + string(uid),
|
|
}
|
|
|
|
return shortURL.String()
|
|
}
|