mirror of
https://github.com/kataras/iris.git
synced 2025-12-22 04:17:03 +00:00
remove 'WithoutVersionChecker', update and test the new versions of some of the dependencies, add a history entry with unknown release date
Former-commit-id: 399db6aac44d3b336648d6d61842f4d7a0266842
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// Article: https://medium.com/@kataras/a-url-shortener-service-using-go-iris-and-bolt-4182f0b00ae7
|
||||
//
|
||||
// $ go get github.com/coreos/bbolt
|
||||
// $ go get github.com/etcd-io/bbolt
|
||||
// $ go get github.com/satori/go.uuid
|
||||
// $ cd $GOPATH/src/github.com/kataras/iris/_examples/tutorial/url-shortener
|
||||
// $ go build
|
||||
|
||||
@@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/coreos/bbolt"
|
||||
"github.com/etcd-io/bbolt"
|
||||
)
|
||||
|
||||
// Panic panics, change it if you don't want to panic on critical INITIALIZE-ONLY-ERRORS
|
||||
@@ -28,17 +28,17 @@ var (
|
||||
// Only one table/bucket which contains the urls, so it's not a fully Database,
|
||||
// it works only with single bucket because that all we need.
|
||||
type DB struct {
|
||||
db *bolt.DB
|
||||
db *bbolt.DB
|
||||
}
|
||||
|
||||
var _ Store = &DB{}
|
||||
|
||||
// openDatabase open a new database connection
|
||||
// and returns its instance.
|
||||
func openDatabase(stumb string) *bolt.DB {
|
||||
func openDatabase(stumb string) *bbolt.DB {
|
||||
// Open the data(base) file in the current working directory.
|
||||
// It will be created if it doesn't exist.
|
||||
db, err := bolt.Open(stumb, 0600, nil)
|
||||
db, err := bbolt.Open(stumb, 0600, nil)
|
||||
if err != nil {
|
||||
Panic(err)
|
||||
}
|
||||
@@ -48,7 +48,7 @@ func openDatabase(stumb string) *bolt.DB {
|
||||
tableURLs,
|
||||
}
|
||||
|
||||
db.Update(func(tx *bolt.Tx) (err error) {
|
||||
db.Update(func(tx *bbolt.Tx) (err error) {
|
||||
for _, table := range tables {
|
||||
_, err = tx.CreateBucketIfNotExists(table)
|
||||
if err != nil {
|
||||
@@ -73,7 +73,7 @@ func NewDB(stumb string) *DB {
|
||||
// Set sets a shorten url and its key
|
||||
// Note: Caller is responsible to generate a key.
|
||||
func (d *DB) Set(key string, value string) error {
|
||||
return d.db.Update(func(tx *bolt.Tx) error {
|
||||
return d.db.Update(func(tx *bbolt.Tx) error {
|
||||
b, err := tx.CreateBucketIfNotExists(tableURLs)
|
||||
// Generate ID for the url
|
||||
// Note: we could use that instead of a random string key
|
||||
@@ -106,7 +106,7 @@ func (d *DB) Set(key string, value string) error {
|
||||
|
||||
// Clear clears all the database entries for the table urls.
|
||||
func (d *DB) Clear() error {
|
||||
return d.db.Update(func(tx *bolt.Tx) error {
|
||||
return d.db.Update(func(tx *bbolt.Tx) error {
|
||||
return tx.DeleteBucket(tableURLs)
|
||||
})
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func (d *DB) Clear() error {
|
||||
// Returns an empty string if not found.
|
||||
func (d *DB) Get(key string) (value string) {
|
||||
keyB := []byte(key)
|
||||
d.db.Update(func(tx *bolt.Tx) error {
|
||||
d.db.Update(func(tx *bbolt.Tx) error {
|
||||
b := tx.Bucket(tableURLs)
|
||||
if b == nil {
|
||||
return nil
|
||||
@@ -138,7 +138,7 @@ func (d *DB) Get(key string) (value string) {
|
||||
// GetByValue returns all keys for a specific (original) url value.
|
||||
func (d *DB) GetByValue(value string) (keys []string) {
|
||||
valueB := []byte(value)
|
||||
d.db.Update(func(tx *bolt.Tx) error {
|
||||
d.db.Update(func(tx *bbolt.Tx) error {
|
||||
b := tx.Bucket(tableURLs)
|
||||
if b == nil {
|
||||
return nil
|
||||
@@ -159,7 +159,7 @@ func (d *DB) GetByValue(value string) (keys []string) {
|
||||
|
||||
// Len returns all the "shorted" urls length
|
||||
func (d *DB) Len() (num int) {
|
||||
d.db.View(func(tx *bolt.Tx) error {
|
||||
d.db.View(func(tx *bbolt.Tx) error {
|
||||
|
||||
// Assume bucket exists and has keys
|
||||
b := tx.Bucket(tableURLs)
|
||||
|
||||
@@ -530,7 +530,7 @@ func main() {
|
||||
todosApp.Handle(new(controllers.TodoController))
|
||||
|
||||
// start the web server at http://localhost:8080
|
||||
app.Run(iris.Addr(":8080"), iris.WithoutVersionChecker)
|
||||
app.Run(iris.Addr(":8080"))
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -51,5 +51,5 @@ func main() {
|
||||
todosApp.Handle(new(controllers.TodoController))
|
||||
|
||||
// start the web server at http://localhost:8080
|
||||
app.Run(iris.Addr(":8080"), iris.WithoutVersionChecker)
|
||||
app.Run(iris.Addr(":8080"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user