update file
This commit is contained in:
1 parent
f810b7bc91
commit
93f354370a
13 files changed
+75
-132
No files matched your search
@@ -1 +1,2 @@
|
||||
bin/tinyurl
|
||||
test/
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
FROM golang:alpine as builder
|
||||
LABEL anther="github.com/Sakurasan"
|
||||
# RUN apt install -y git make
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk update && apk --no-cache add make git
|
||||
LABEL anther="cjun"
|
||||
WORKDIR /tinyurl
|
||||
COPY . /tinyurl
|
||||
ENV GO111MODULE=on
|
||||
|
||||
+6
-6
@@ -5,7 +5,7 @@ server:
|
||||
data:
|
||||
database:
|
||||
driver: mysql
|
||||
source: root:root@tcp(127.0.0.1:3306)/test
|
||||
source: tinyurl:tinyurl@tcp(127.0.0.1:3306)/tinyurl?charset=utf8mb4&parseTime=True&loc=Local
|
||||
redis:
|
||||
addr: 127.0.0.1:6379
|
||||
read_timeout: 0.2s
|
||||
@@ -16,8 +16,8 @@ log:
|
||||
development: true
|
||||
rotate:
|
||||
filename: ./app.log
|
||||
maxsize: 10
|
||||
maxage: 7
|
||||
maxbackups:
|
||||
localtime:
|
||||
compress:
|
||||
maxsize: 10 #Mb
|
||||
maxage: 7 #day
|
||||
# maxbackups:
|
||||
# localtime:
|
||||
# compress:
|
||||
@@ -303,4 +303,4 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||
* https://clipboardjs.com/
|
||||
*
|
||||
* Licensed MIT © Zeno Rocha
|
||||
*/(function(e,t){(function(r,o){e.exports=o()})(vh,function(){return function(){var n={686:function(s,a,i){i.d(a,{default:function(){return ot}});var l=i(279),c=i.n(l),u=i(370),d=i.n(u),g=i(817),v=i.n(g);function A(I){try{return document.execCommand(I)}catch{return!1}}var $=function(L){var P=v()(L);return A("cut"),P},C=$;function E(I){var L=document.documentElement.getAttribute("dir")==="rtl",P=document.createElement("textarea");P.style.fontSize="12pt",P.style.border="0",P.style.padding="0",P.style.margin="0",P.style.position="absolute",P.style[L?"right":"left"]="-9999px";var D=window.pageYOffset||document.documentElement.scrollTop;return P.style.top="".concat(D,"px"),P.setAttribute("readonly",""),P.value=I,P}var K=function(L){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},D="";if(typeof L=="string"){var N=E(L);P.container.appendChild(N),D=v()(N),A("copy"),N.remove()}else D=v()(L),A("copy");return D},q=K;function V(I){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?V=function(P){return typeof P}:V=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},V(I)}var pe=function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},P=L.action,D=P===void 0?"copy":P,N=L.container,Q=L.target,ce=L.text;if(D!=="copy"&&D!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(Q!==void 0)if(Q&&V(Q)==="object"&&Q.nodeType===1){if(D==="copy"&&Q.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(D==="cut"&&(Q.hasAttribute("readonly")||Q.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(ce)return q(ce,{container:N});if(Q)return D==="cut"?C(Q):q(Q,{container:N})},Ee=pe;function W(I){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?W=function(P){return typeof P}:W=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},W(I)}function ae(I,L){if(!(I instanceof L))throw new TypeError("Cannot call a class as a function")}function re(I,L){for(var P=0;P<L.length;P++){var D=L[P];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(I,D.key,D)}}function _e(I,L,P){return L&&re(I.prototype,L),P&&re(I,P),I}function me(I,L){if(typeof L!="function"&&L!==null)throw new TypeError("Super expression must either be null or a function");I.prototype=Object.create(L&&L.prototype,{constructor:{value:I,writable:!0,configurable:!0}}),L&&O(I,L)}function O(I,L){return O=Object.setPrototypeOf||function(D,N){return D.__proto__=N,D},O(I,L)}function ne(I){var L=le();return function(){var D=ee(I),N;if(L){var Q=ee(this).constructor;N=Reflect.construct(D,arguments,Q)}else N=D.apply(this,arguments);return Te(this,N)}}function Te(I,L){return L&&(W(L)==="object"||typeof L=="function")?L:je(I)}function je(I){if(I===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return I}function le(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function ee(I){return ee=Object.setPrototypeOf?Object.getPrototypeOf:function(P){return P.__proto__||Object.getPrototypeOf(P)},ee(I)}function te(I,L){var P="data-clipboard-".concat(I);if(!!L.hasAttribute(P))return L.getAttribute(P)}var Re=function(I){me(P,I);var L=ne(P);function P(D,N){var Q;return ae(this,P),Q=L.call(this),Q.resolveOptions(N),Q.listenClick(D),Q}return _e(P,[{key:"resolveOptions",value:function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof N.action=="function"?N.action:this.defaultAction,this.target=typeof N.target=="function"?N.target:this.defaultTarget,this.text=typeof N.text=="function"?N.text:this.defaultText,this.container=W(N.container)==="object"?N.container:document.body}},{key:"listenClick",value:function(N){var Q=this;this.listener=d()(N,"click",function(ce){return Q.onClick(ce)})}},{key:"onClick",value:function(N){var Q=N.delegateTarget||N.currentTarget,ce=this.action(Q)||"copy",Ke=Ee({action:ce,container:this.container,target:this.target(Q),text:this.text(Q)});this.emit(Ke?"success":"error",{action:ce,text:Ke,trigger:Q,clearSelection:function(){Q&&Q.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(N){return te("action",N)}},{key:"defaultTarget",value:function(N){var Q=te("target",N);if(Q)return document.querySelector(Q)}},{key:"defaultText",value:function(N){return te("text",N)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(N){var Q=Line truncated
|
||||
*/(function(e,t){(function(r,o){e.exports=o()})(vh,function(){return function(){var n={686:function(s,a,i){i.d(a,{default:function(){return ot}});var l=i(279),c=i.n(l),u=i(370),d=i.n(u),g=i(817),v=i.n(g);function A(I){try{return document.execCommand(I)}catch{return!1}}var $=function(L){var P=v()(L);return A("cut"),P},C=$;function E(I){var L=document.documentElement.getAttribute("dir")==="rtl",P=document.createElement("textarea");P.style.fontSize="12pt",P.style.border="0",P.style.padding="0",P.style.margin="0",P.style.position="absolute",P.style[L?"right":"left"]="-9999px";var D=window.pageYOffset||document.documentElement.scrollTop;return P.style.top="".concat(D,"px"),P.setAttribute("readonly",""),P.value=I,P}var K=function(L){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},D="";if(typeof L=="string"){var N=E(L);P.container.appendChild(N),D=v()(N),A("copy"),N.remove()}else D=v()(L),A("copy");return D},q=K;function V(I){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?V=function(P){return typeof P}:V=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},V(I)}var pe=function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},P=L.action,D=P===void 0?"copy":P,N=L.container,Q=L.target,ce=L.text;if(D!=="copy"&&D!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(Q!==void 0)if(Q&&V(Q)==="object"&&Q.nodeType===1){if(D==="copy"&&Q.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(D==="cut"&&(Q.hasAttribute("readonly")||Q.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(ce)return q(ce,{container:N});if(Q)return D==="cut"?C(Q):q(Q,{container:N})},Ee=pe;function W(I){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?W=function(P){return typeof P}:W=function(P){return P&&typeof Symbol=="function"&&P.constructor===Symbol&&P!==Symbol.prototype?"symbol":typeof P},W(I)}function ae(I,L){if(!(I instanceof L))throw new TypeError("Cannot call a class as a function")}function re(I,L){for(var P=0;P<L.length;P++){var D=L[P];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(I,D.key,D)}}function _e(I,L,P){return L&&re(I.prototype,L),P&&re(I,P),I}function me(I,L){if(typeof L!="function"&&L!==null)throw new TypeError("Super expression must either be null or a function");I.prototype=Object.create(L&&L.prototype,{constructor:{value:I,writable:!0,configurable:!0}}),L&&O(I,L)}function O(I,L){return O=Object.setPrototypeOf||function(D,N){return D.__proto__=N,D},O(I,L)}function ne(I){var L=le();return function(){var D=ee(I),N;if(L){var Q=ee(this).constructor;N=Reflect.construct(D,arguments,Q)}else N=D.apply(this,arguments);return Te(this,N)}}function Te(I,L){return L&&(W(L)==="object"||typeof L=="function")?L:je(I)}function je(I){if(I===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return I}function le(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function ee(I){return ee=Object.setPrototypeOf?Object.getPrototypeOf:function(P){return P.__proto__||Object.getPrototypeOf(P)},ee(I)}function te(I,L){var P="data-clipboard-".concat(I);if(!!L.hasAttribute(P))return L.getAttribute(P)}var Re=function(I){me(P,I);var L=ne(P);function P(D,N){var Q;return ae(this,P),Q=L.call(this),Q.resolveOptions(N),Q.listenClick(D),Q}return _e(P,[{key:"resolveOptions",value:function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof N.action=="function"?N.action:this.defaultAction,this.target=typeof N.target=="function"?N.target:this.defaultTarget,this.text=typeof N.text=="function"?N.text:this.defaultText,this.container=W(N.container)==="object"?N.container:document.body}},{key:"listenClick",value:function(N){var Q=this;this.listener=d()(N,"click",function(ce){return Q.onClick(ce)})}},{key:"onClick",value:function(N){var Q=N.delegateTarget||N.currentTarget,ce=this.action(Q)||"copy",Ke=Ee({action:ce,container:this.container,target:this.target(Q),text:this.text(Q)});this.emit(Ke?"success":"error",{action:ce,text:Ke,trigger:Q,clearSelection:function(){Q&&Q.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(N){return te("action",N)}},{key:"defaultTarget",value:function(N){var Q=te("target",N);if(Q)return document.querySelector(Q)}},{key:"defaultText",value:function(N){return te("text",N)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(N){var Q=Line truncated
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>TinyUrl</title>
|
||||
<script type="module" crossorigin src="/assets/index.b2aedd95.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index.a180db26.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index.cf87a41a.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
version: '3'
|
||||
services:
|
||||
tinyurl:
|
||||
# The official v2 Traefik docker image
|
||||
image: mirrors2/tinyurl
|
||||
container_name: tinyurl
|
||||
restart: always
|
||||
ports:
|
||||
- "2830:2830"
|
||||
# volumes: #default log term
|
||||
# - $PWD/log:/app/tinyurl/log
|
||||
# - config.yml:/app/tinyurl/configs/config.yml
|
||||
entrypoint:
|
||||
- DSN=tinyurl:tinyurl@tcp(db:3306)/tinyurl?charset=utf8mb4
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
|
||||
tinyurl_db:
|
||||
image: mariadb
|
||||
container_name: tinyurl_db
|
||||
restart: always
|
||||
networks:
|
||||
- gitea
|
||||
expose:
|
||||
- 3306
|
||||
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=supermen
|
||||
- MYSQL_DATABASE=tinyurl
|
||||
- MYSQL_USER=tinyurl
|
||||
- MYSQL_PASSWORD=tinyurl
|
||||
- TZ=Asia/Shanghai
|
||||
volumes:
|
||||
- ./db:/var/lib/mysql
|
||||
# 标准 Linux 系统下使用
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
# healthcheck:
|
||||
# test: ["CMD-SHELL", "/etc/init.d/mysql status"]
|
||||
# interval: 30s
|
||||
+10
-3
@@ -1,6 +1,7 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"gorm.io/driver/mysql"
|
||||
@@ -13,10 +14,11 @@ var (
|
||||
|
||||
type TinyUrl struct {
|
||||
gorm.Model
|
||||
LongUrl string `gorm:"size:200"`
|
||||
ShortUrl string `gorm:"size:50"`
|
||||
LongUrl string `gorm:"size:7713"`
|
||||
ShortUrl string `gorm:"size:20"`
|
||||
ExpireTime time.Time
|
||||
Counter float64
|
||||
AddIP string
|
||||
}
|
||||
|
||||
type URLDetail struct {
|
||||
@@ -27,7 +29,12 @@ type URLDetail struct {
|
||||
|
||||
func InitDb() {
|
||||
// 参考 https://github.com/go-sql-driver/mysql#dsn-data-source-name 获取详情
|
||||
dsn := "tinyurl:tinyurl@tcp(42.192.36.14:3306)/tinyurl?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
var dsn string
|
||||
if len(os.Getenv("DSN")) > 1 {
|
||||
dsn = os.Getenv("DSN")
|
||||
} else {
|
||||
dsn = "tinyurl:tinyurl@tcp(42.192.36.14:3306)/tinyurl?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
}
|
||||
var err error
|
||||
DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
||||
if err != nil {
|
||||
|
||||
+5
-5
@@ -85,11 +85,11 @@ func getConsoleEncoder() zapcore.Encoder {
|
||||
func getFileWriter(c config.Rotate) zapcore.WriteSyncer {
|
||||
logger := &lumberjack.Logger{
|
||||
Filename: c.Filename,
|
||||
MaxSize: c.MaxSize,
|
||||
MaxAge: c.MaxAge,
|
||||
MaxBackups: c.MaxBackups,
|
||||
LocalTime: c.LocalTime,
|
||||
Compress: c.Compress,
|
||||
MaxSize: c.MaxSize, //Mb
|
||||
MaxAge: c.MaxAge, //days
|
||||
MaxBackups: c.MaxBackups, //int backup maximum number of old log files
|
||||
LocalTime: c.LocalTime, //bool backup files is the computer's local time
|
||||
Compress: c.Compress, //bool
|
||||
}
|
||||
return zapcore.AddSync(logger)
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ import (
|
||||
func Route(f *flamego.Flame) {
|
||||
f.Get("/version", auth.Basic("admin", "admin"), func() string { return "1.1.1" })
|
||||
// f.Get("/{url: **, capture: 10}", tinyurl.TinyurlHandler)
|
||||
f.Get("/{url: **, capture: 10}", tinyurl.TinyUtlTo)
|
||||
f.Router.Any("/api/v1/tiny", binding.JSON(tinyurl.Param{}), tinyurl.TinyUrl)
|
||||
f.Get("/{url: **, capture: 10}", tinyurl.TinyUrlTo)
|
||||
f.Post("/api/v1/tiny", binding.JSON(tinyurl.Param{}), tinyurl.TinyUrl)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
"tinyurl/pkg/base62"
|
||||
"tinyurl/pkg/config"
|
||||
@@ -53,18 +54,15 @@ func TinyUrl(c flamego.Context, w http.ResponseWriter, form Param, errs binding.
|
||||
_, _ = c.ResponseWriter().Write([]byte(fmt.Sprintf("Oops! Error occurred: %v", err)))
|
||||
return
|
||||
}
|
||||
if !strings.HasPrefix(form.LongUrl, "http://") || !strings.HasPrefix(form.LongUrl, "https://") {
|
||||
form.LongUrl = "http://" + form.LongUrl
|
||||
}
|
||||
logger.Info(c.Request().Context(), form.LongUrl)
|
||||
var tm = data.TinyUrl{}
|
||||
tm.LongUrl = form.LongUrl
|
||||
tm.ShortUrl = base62.TinyUrl(form.LongUrl + time.Now().String())
|
||||
tm.ShortUrl = base62.TinyUrl(form.LongUrl + "?" + time.Now().String())
|
||||
if err := db.Create(&tm).Error; err != nil {
|
||||
logger.Info(c.Request().Context(), err.Error())
|
||||
// bytejson, _ := json.Marshal(map[string]interface{}{
|
||||
// "code": http.StatusBadGateway,
|
||||
// "msg": "please try again",
|
||||
// })
|
||||
// io.WriteString(c.ResponseWriter(), string(bytejson))
|
||||
// return
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"code": http.StatusBadGateway,
|
||||
@@ -78,19 +76,10 @@ func TinyUrl(c flamego.Context, w http.ResponseWriter, form Param, errs binding.
|
||||
"msg": "success",
|
||||
"shortUrl": cfg.Server.Domain + tm.ShortUrl,
|
||||
})
|
||||
// bytejson, err := json.Marshal(map[string]interface{}{
|
||||
// "code": http.StatusOK,
|
||||
// "msg": "success",
|
||||
// "shortUrl": tm.ShortUrl,
|
||||
// })
|
||||
// if err != nil {
|
||||
// logger.Error(c.Request().Context(), err.Error())
|
||||
// }
|
||||
// io.WriteString(c.ResponseWriter(), string(bytejson))
|
||||
|
||||
}
|
||||
|
||||
func TinyUtlTo(c flamego.Context, logger *log.Logger, db *gorm.DB, l *lru.Cache, cfg *config.Config) {
|
||||
func TinyUrlTo(c flamego.Context, logger *log.Logger, db *gorm.DB, l *lru.Cache, cfg *config.Config) {
|
||||
tiny := c.Param("url")
|
||||
if v, ok := l.Get(tiny); ok {
|
||||
c.Redirect(v.(string), http.StatusFound)
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
dlpath := "http://pan.oneisall.xyz/Outline.apk"
|
||||
req, _ := http.NewRequest(http.MethodHead, dlpath, nil)
|
||||
rsp, _ := http.DefaultClient.Do(req)
|
||||
defer rsp.Body.Close()
|
||||
fmt.Println(rsp.Status)
|
||||
// dump, _ := httputil.DumpResponse(rsp, false)
|
||||
// fmt.Println(string(dump))
|
||||
// if rsp.Header != nil {
|
||||
// fmt.Printf("%v", rsp.Header)
|
||||
for k, v := range rsp.Header {
|
||||
fmt.Println(k, v)
|
||||
}
|
||||
fmt.Println(rsp.Header.Get("Content-Length"))
|
||||
fmt.Println(rsp.Header.Get("Accept-Ranges"))
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
bytereq, _ := httputil.DumpRequest(r, true)
|
||||
bytebody, _ := io.ReadAll(r.Body)
|
||||
log.Println(string(bytereq))
|
||||
m := map[string]interface{}{
|
||||
"host": r.Host,
|
||||
"requestUrl": r.RequestURI,
|
||||
"proto": r.Proto,
|
||||
"path": r.URL.String(),
|
||||
"method": r.Method,
|
||||
"body": string(bytebody),
|
||||
"header": r.Header,
|
||||
"form": r.Form,
|
||||
"postform": r.PostForm,
|
||||
"dumpreq": string(bytereq),
|
||||
}
|
||||
bj, _ := json.Marshal(m)
|
||||
fmt.Println(string(bj))
|
||||
// json.NewEncoder(w).Encode(m)
|
||||
|
||||
for k, v := range cors {
|
||||
w.Header().Set(k, v)
|
||||
}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
io.WriteString(w, string(bj))
|
||||
return
|
||||
})
|
||||
server := http.Server{
|
||||
Addr: ":890",
|
||||
Handler: mux,
|
||||
}
|
||||
server.ListenAndServe()
|
||||
}
|
||||
|
||||
var cors = map[string]string{
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Methods": "POST,OPTIONS,GET",
|
||||
"Access-Control-Max-Age": "3600",
|
||||
"Access-Control-Allow-Headers": "accept,x-requested-with,Content-Type",
|
||||
"Access-Control-Allow-Credentials": "true",
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
)
|
||||
|
||||
func main() {
|
||||
l, _ := lru.New(10)
|
||||
for i := 0; i < 100; i++ {
|
||||
l.Add(i, i)
|
||||
}
|
||||
for l.Len() > 0 {
|
||||
fmt.Println(l.RemoveOldest())
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user