Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
db142def3f | |
|
60bc6071f2 |
|
@ -0,0 +1,10 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="run" type="GoApplicationRunConfiguration" factoryName="Go Application">
|
||||
<module name="skimmer" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<kind value="DIRECTORY" />
|
||||
<directory value="$PROJECT_DIR$/src" />
|
||||
<filePath value="$PROJECT_DIR$" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
|
@ -0,0 +1,22 @@
|
|||
module git.tiburon.su/USEFULL/skimmer
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/codegangsta/martini v0.0.0-20170121215854-22fa46961aab
|
||||
github.com/codegangsta/martini-contrib v0.0.0-20140208234550-8ce6181c2609
|
||||
github.com/garyburd/redigo v1.6.3
|
||||
github.com/stretchr/testify v1.8.0
|
||||
github.com/ugorji/go/codec v1.2.7
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/gorilla/context v1.1.1 // indirect
|
||||
github.com/gorilla/securecookie v1.1.1 // indirect
|
||||
github.com/gorilla/sessions v1.2.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/objx v0.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
|
@ -0,0 +1,33 @@
|
|||
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 h1:sDMmm+q/3+BukdIpxwO365v/Rbspp2Nt5XntgQRXq8Q=
|
||||
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
|
||||
github.com/codegangsta/martini v0.0.0-20170121215854-22fa46961aab h1:eFEFkK1s2OXNiIOvjNT5lk/AGXQodN2l8VgbkCK9r4c=
|
||||
github.com/codegangsta/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:0SkifPRh0YknjZR6LxtP+eMvgPwUI6DG8hE9U/3dW9E=
|
||||
github.com/codegangsta/martini-contrib v0.0.0-20140208234550-8ce6181c2609 h1:aRxx5sQikIjKQPDVpYbEjaUSrj58MM5kfxX2wS9nNNQ=
|
||||
github.com/codegangsta/martini-contrib v0.0.0-20140208234550-8ce6181c2609/go.mod h1:Hr/9ecwnTZD7izDjg7HoB5wOJ01ZbNo+ntSTza2hqR4=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/garyburd/redigo v1.6.3 h1:HCeeRluvAgMusMomi1+6Y5dmFOdYV/JzoRrrbFlkGIc=
|
||||
github.com/garyburd/redigo v1.6.3/go.mod h1:rTb6epsqigu3kYKBnaF028A7Tf/Aw5s0cqA47doKKqw=
|
||||
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
|
||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||
github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI=
|
||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
|
||||
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
|
||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
@ -1,12 +1,14 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"skimmer"
|
||||
"flag"
|
||||
"fmt"
|
||||
"git.tiburon.su/USEFULL/skimmer/skimmer"
|
||||
)
|
||||
|
||||
var (
|
||||
config = skimmer.Config{
|
||||
Address: "localhost:3000",
|
||||
SessionSecret: "secret123",
|
||||
RedisConfig: skimmer.RedisConfig{
|
||||
RedisAddr: "127.0.0.1:6379",
|
||||
|
@ -27,5 +29,6 @@ func init() {
|
|||
func main() {
|
||||
flag.Parse()
|
||||
api := skimmer.GetApi(&config)
|
||||
api.Run()
|
||||
fmt.Printf("Open in brouser http://%s\n", config.Address)
|
||||
api.RunOnAddr(config.Address)
|
||||
}
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
package skimmer
|
||||
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/codegangsta/martini"
|
||||
"github.com/codegangsta/martini-contrib/render"
|
||||
"github.com/codegangsta/martini-contrib/sessions"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"github.com/codegangsta/martini-contrib/sessions"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
|
||||
|
||||
type ErrorMsg struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
@ -29,6 +26,7 @@ type RedisConfig struct {
|
|||
}
|
||||
|
||||
type Config struct {
|
||||
Address string
|
||||
SessionSecret string
|
||||
Storage string
|
||||
RedisConfig
|
||||
|
@ -47,7 +45,6 @@ func GetApi(config *Config) *martini.ClassicMartini {
|
|||
memoryStorage.StartCleaning(60)
|
||||
storage = memoryStorage
|
||||
|
||||
|
||||
}
|
||||
store := sessions.NewCookieStore([]byte(config.SessionSecret))
|
||||
|
||||
|
@ -62,7 +59,6 @@ func GetApi(config *Config) *martini.ClassicMartini {
|
|||
api.Use(sessions.Sessions("my_session", store))
|
||||
api.Use(NewSessionHistoryHandler(20, "binHistory"))
|
||||
|
||||
|
||||
api.Post("/api/v1/bins/", func(r render.Render, storage Storage, history History, session sessions.Session, req *http.Request) {
|
||||
payload := Bin{}
|
||||
if err := DecodeJsonPayload(req, &payload); err != nil {
|
||||
|
|
Loading…
Reference in New Issue