Golang 1.5 and gzip

This commit is contained in:
Matthew Dillon 2015-09-09 19:01:45 -07:00
parent 12b460db9a
commit 44387aa14b
68 changed files with 347 additions and 85 deletions

9
Godeps/Godeps.json generated
View file

@ -1,6 +1,9 @@
{
"ImportPath": "github.com/thermokarst/bactdb",
"GoVersion": "go1.4.2",
"GoVersion": "go1.5",
"Packages": [
"./..."
],
"Deps": [
{
"ImportPath": "github.com/DavidHuie/gomigrate",
@ -45,6 +48,10 @@
"ImportPath": "github.com/mbanzon/simplehttp",
"Rev": "04c542e7ac706a25820090f274ea6a4f39a63326"
},
{
"ImportPath": "github.com/nytimes/gziphandler",
"Rev": "05ffaf97c37e486a9b983089cc4865a1b0a9a651"
},
{
"ImportPath": "github.com/thermokarst/jwt",
"Rev": "7752009bbb5cea39ab392a846c467eab4b98478f"

View file

@ -8,7 +8,7 @@ import (
"testing"
_ "github.com/go-sql-driver/mysql"
_ "github.com/lib/pq"
_ "github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq"
)
var (

View file

@ -6,7 +6,7 @@ import (
"os"
"testing"
"github.com/codegangsta/cli"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/codegangsta/cli"
)
func ExampleApp() {

View file

@ -3,7 +3,7 @@ package cli_test
import (
"os"
"github.com/codegangsta/cli"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/codegangsta/cli"
)
func Example() {

View file

@ -4,7 +4,7 @@ import (
"flag"
"testing"
"github.com/codegangsta/cli"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/codegangsta/cli"
)
func TestCommandDoNotIgnoreFlags(t *testing.T) {

View file

@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/codegangsta/cli"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/codegangsta/cli"
)
func TestNewContext(t *testing.T) {

View file

@ -7,7 +7,7 @@ import (
"strings"
"testing"
"github.com/codegangsta/cli"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/codegangsta/cli"
)
var boolFlagTests = []struct {

View file

@ -9,7 +9,7 @@ import (
"net/http"
"path"
"github.com/gorilla/context"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/gorilla/context"
)
// NewRouter returns a new router instance.

View file

@ -9,7 +9,7 @@ import (
"net/http"
"testing"
"github.com/gorilla/context"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/gorilla/context"
)
type routeTest struct {

View file

@ -18,8 +18,8 @@ import (
"reflect"
"strings"
"github.com/jmoiron/sqlx"
"github.com/jmoiron/sqlx/reflectx"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/sqlx"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/sqlx/reflectx"
)
// TableNameMapper is the function used by AddTable to map struct names to database table names, in analogy

View file

@ -6,7 +6,7 @@ import (
"reflect"
"strings"
"github.com/jmoiron/sqlx"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/sqlx"
)
// Dialect is an interface that encapsulates behaviors that differ across

View file

@ -3,7 +3,7 @@ package modl
import (
"database/sql"
"github.com/jmoiron/sqlx"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/sqlx"
)
// a cursor is either an sqlx.Db or an sqlx.Tx

View file

@ -11,8 +11,8 @@ import (
"time"
_ "github.com/go-sql-driver/mysql"
_ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3"
_ "github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq"
)
var _ = log.Fatal

View file

@ -5,8 +5,8 @@ import (
"fmt"
"reflect"
"github.com/jmoiron/sqlx"
"github.com/jmoiron/sqlx/reflectx"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/sqlx"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/sqlx/reflectx"
)
// TableMap represents a mapping between a Go struct and a database table

View file

@ -3,7 +3,7 @@ package modl
import (
"database/sql"
"github.com/jmoiron/sqlx"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/sqlx"
)
// Transaction represents a database transaction.

View file

@ -19,7 +19,7 @@ import (
"strconv"
"unicode"
"github.com/jmoiron/sqlx/reflectx"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/sqlx/reflectx"
)
// NamedStmt is a prepared statement that executes named queries. Prepare it

View file

@ -11,7 +11,7 @@ import (
"reflect"
"strings"
"github.com/jmoiron/sqlx/reflectx"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/sqlx/reflectx"
)
// Although the NameMapper is convenient, in practice it should not

View file

@ -23,9 +23,9 @@ import (
"time"
_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx/reflectx"
_ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/sqlx/reflectx"
_ "github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq"
)
/* compile time checks that Db, Tx, Stmt (qStmt) implement expected interfaces */

View file

@ -17,7 +17,7 @@ import (
"testing"
"time"
"github.com/lib/pq/oid"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq/oid"
)
var (

View file

@ -4,7 +4,7 @@ import (
"bytes"
"encoding/binary"
"github.com/lib/pq/oid"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq/oid"
)
type readBuf []byte

View file

@ -22,7 +22,7 @@ import (
"time"
"unicode"
"github.com/lib/pq/oid"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq/oid"
)
// Common error types

View file

@ -11,7 +11,7 @@ import (
"sync"
"time"
"github.com/lib/pq/oid"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq/oid"
)
func encode(parameterStatus *parameterStatus, x interface{}, pgtypOid oid.Oid) []byte {

View file

@ -6,7 +6,7 @@ import (
"testing"
"time"
"github.com/lib/pq/oid"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq/oid"
)
func TestScanTimestamp(t *testing.T) {

View file

@ -5,7 +5,7 @@ import (
"os"
"testing"
_ "github.com/lib/pq"
_ "github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq"
)
type Fatalistic interface {

View file

@ -11,7 +11,7 @@ import (
"os"
"os/exec"
_ "github.com/lib/pq"
_ "github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq"
)
func main() {

View file

@ -4,7 +4,7 @@ package acceptance
import (
"fmt"
mailgun "github.com/mailgun/mailgun-go"
mailgun "github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"testing"
)

View file

@ -4,7 +4,7 @@ package acceptance
import (
"fmt"
mailgun "github.com/mailgun/mailgun-go"
mailgun "github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"os"
"testing"
"text/tabwriter"

View file

@ -5,7 +5,7 @@ package acceptance
import (
"crypto/rand"
"fmt"
"github.com/mailgun/mailgun-go"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"testing"
)
@ -49,7 +49,7 @@ func TestGetSingleDomainNotExist(t *testing.T) {
domain := reqEnv(t, "MG_DOMAIN")
apiKey := reqEnv(t, "MG_API_KEY")
mg := mailgun.NewMailgun(domain, apiKey, "")
_, _, _, err := mg.GetSingleDomain(randomString(32, "com.edu.org.")+".com")
_, _, _, err := mg.GetSingleDomain(randomString(32, "com.edu.org.") + ".com")
if err == nil {
t.Fatal("Did not expect a domain to exist")
}

View file

@ -3,7 +3,7 @@
package acceptance
import (
"github.com/mailgun/mailgun-go"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"testing"
)

View file

@ -4,7 +4,7 @@ package acceptance
import (
"fmt"
"github.com/mailgun/mailgun-go"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"os"
"testing"
"text/tabwriter"

View file

@ -4,7 +4,7 @@ package acceptance
import (
"fmt"
mailgun "github.com/mailgun/mailgun-go"
mailgun "github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"testing"
)

View file

@ -4,7 +4,7 @@ package acceptance
import (
"fmt"
mailgun "github.com/mailgun/mailgun-go"
mailgun "github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"io/ioutil"
"strings"
"testing"
@ -169,7 +169,7 @@ func TestGetStoredMessage(t *testing.T) {
func findStoredMessageID(mg mailgun.Mailgun) (string, error) {
ei := mg.NewEventIterator()
err := ei.GetFirstPage(mailgun.GetEventsOptions{})
for{
for {
if err != nil {
return "", err
}
@ -299,7 +299,7 @@ func TestSendMGBatchFailRecipients(t *testing.T) {
mg := mailgun.NewMailgun(domain, apiKey, "")
m := mg.NewMessage(fromUser, exampleSubject, exampleText+"Batch\n")
for i := 0; i < mailgun.MaxNumberOfRecipients; i++ {
m.AddRecipient("") // We expect this to indicate a failure at the API
m.AddRecipient("") // We expect this to indicate a failure at the API
}
err := m.AddRecipientAndVariables(toUser, nil)
if err == nil {
@ -316,7 +316,7 @@ func TestSendMGBatchRecipientVariables(t *testing.T) {
mg := mailgun.NewMailgun(domain, apiKey, "")
m := mg.NewMessage(fromUser, exampleSubject, templateText)
err := m.AddRecipientAndVariables(toUser, map[string]interface{}{
"name": "Joe Cool Example",
"name": "Joe Cool Example",
"table": 42,
})
if err != nil {

View file

@ -3,7 +3,7 @@
package acceptance
import (
"github.com/mailgun/mailgun-go"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"testing"
)

View file

@ -3,7 +3,7 @@
package acceptance
import (
"github.com/mailgun/mailgun-go"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"testing"
)

View file

@ -4,7 +4,7 @@ package acceptance
import (
"fmt"
mailgun "github.com/mailgun/mailgun-go"
mailgun "github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"os"
"testing"
"text/tabwriter"

View file

@ -4,7 +4,7 @@ package acceptance
import (
"fmt"
mailgun "github.com/mailgun/mailgun-go"
mailgun "github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"os"
"testing"
"text/tabwriter"

View file

@ -3,7 +3,7 @@
package acceptance
import (
"github.com/mailgun/mailgun-go"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"testing"
)

View file

@ -1,7 +1,7 @@
package mailgun
import (
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
"strconv"
"time"
)

View file

@ -1,7 +1,7 @@
package mailgun
import (
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
)
// Campaigns have been deprecated since development work on this SDK commenced.

View file

@ -2,7 +2,7 @@ package mailgun
import (
"fmt"
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
"strconv"
)

View file

@ -1,7 +1,7 @@
package mailgun
import (
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
"strconv"
"time"
)

View file

@ -1,7 +1,7 @@
package mailgun
import (
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
"strings"
)

View file

@ -2,7 +2,7 @@ package mailgun
import (
"fmt"
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
"time"
)

View file

@ -94,7 +94,7 @@ package mailgun
import (
"fmt"
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
"io"
"time"
)

View file

@ -3,7 +3,7 @@ package mailgun
import (
"encoding/json"
"fmt"
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
"strconv"
)

View file

@ -6,7 +6,7 @@ import (
"io"
"time"
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
)
// MaxNumberOfRecipients represents the largest batch of recipients that Mailgun can support in a single API call.

View file

@ -2,7 +2,7 @@ package mailgun
import (
"fmt"
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
)
// The MailgunGoUserAgent identifies the client to the server, for logging purposes.

View file

@ -1,7 +1,7 @@
package mailgun
import (
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
"strconv"
)

View file

@ -1,7 +1,7 @@
package mailgun
import (
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
"strconv"
)

View file

@ -1,7 +1,7 @@
package mailgun
import (
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
"strconv"
"time"
)

View file

@ -1,7 +1,7 @@
package mailgun
import (
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
"strconv"
)

View file

@ -1,7 +1,7 @@
package mailgun
import (
"github.com/mbanzon/simplehttp"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mbanzon/simplehttp"
)
// GetWebhooks returns the complete set of webhooks configured for your domain.

View file

@ -0,0 +1,13 @@
Copyright (c) 2015 The New York Times Company
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this library except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -0,0 +1,52 @@
Gzip Handler
============
This is a tiny Go package which wraps HTTP handlers to transparently gzip the
response body, for clients which support it. Although it's usually simpler to
leave that to a reverse proxy (like nginx or Varnish), this package is useful
when that's undesirable.
## Usage
Call `GzipHandler` with any handler (an object which implements the
`http.Handler` interface), and it'll return a new handler which gzips the
response. For example:
```go
package main
import (
"io"
"net/http"
"github.com/nytimes/gziphandler"
)
func main() {
withoutGz := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
io.WriteString(w, "Hello, World")
})
withGz := gziphandler.GzipHandler(withoutGz)
http.Handle("/", withGz)
http.ListenAndServe("0.0.0.0:8000", nil)
}
```
## Documentation
The docs can be found at [godoc.org] [docs], as usual.
## License
[Apache 2.0] [license].
[docs]: https://godoc.org/github.com/nytimes/gziphandler
[license]: https://github.com/nytimes/gziphandler/blob/master/LICENSE.md

View file

@ -0,0 +1,118 @@
package gziphandler
import (
"compress/gzip"
"fmt"
"io"
"net/http"
"strconv"
"strings"
)
type codings map[string]float64
// The default qvalue to assign to an encoding if no explicit qvalue is set.
// This is actually kind of ambiguous in RFC 2616, so hopefully it's correct.
// The examples seem to indicate that it is.
const DEFAULT_QVALUE = 1.0
// GzipResponseWriter provides an http.ResponseWriter interface, which gzips
// bytes before writing them to the underlying response. This doesn't set the
// Content-Encoding header, nor close the writers, so don't forget to do that.
type GzipResponseWriter struct {
io.Writer
http.ResponseWriter
}
// Write appends data to the gzip writer.
func (gzw GzipResponseWriter) Write(b []byte) (int, error) {
return gzw.Writer.Write(b)
}
// GzipHandler wraps an HTTP handler, to transparently gzip the response body if
// the client supports it (via the Accept-Encoding header).
func GzipHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if acceptsGzip(r) {
// Bytes written during ServeHTTP are redirected to this gzip writer
// before being written to the underlying response.
gzw := gzip.NewWriter(w)
defer gzw.Close()
w.Header().Set("Content-Encoding", "gzip")
h.ServeHTTP(GzipResponseWriter{gzw, w}, r)
} else {
h.ServeHTTP(w, r)
}
})
}
// acceptsGzip returns true if the given HTTP request indicates that it will
// accept a gzippped response.
func acceptsGzip(r *http.Request) bool {
acceptedEncodings, _ := parseEncodings(r.Header.Get("Accept-Encoding"))
return acceptedEncodings["gzip"] > 0.0
}
// parseEncodings attempts to parse a list of codings, per RFC 2616, as might
// appear in an Accept-Encoding header. It returns a map of content-codings to
// quality values, and an error containing the errors encounted. It's probably
// safe to ignore those, because silently ignoring errors is how the internet
// works.
//
// See: http://tools.ietf.org/html/rfc2616#section-14.3
func parseEncodings(s string) (codings, error) {
c := make(codings)
e := make([]string, 0)
for _, ss := range strings.Split(s, ",") {
coding, qvalue, err := parseCoding(ss)
if err != nil {
e = append(e, err.Error())
} else {
c[coding] = qvalue
}
}
// TODO (adammck): Use a proper multi-error struct, so the individual errors
// can be extracted if anyone cares.
if len(e) > 0 {
return c, fmt.Errorf("errors while parsing encodings: %s", strings.Join(e, ", "))
}
return c, nil
}
// parseCoding parses a single conding (content-coding with an optional qvalue),
// as might appear in an Accept-Encoding header. It attempts to forgive minor
// formatting errors.
func parseCoding(s string) (coding string, qvalue float64, err error) {
for n, part := range strings.Split(s, ";") {
part = strings.TrimSpace(part)
qvalue = DEFAULT_QVALUE
if n == 0 {
coding = strings.ToLower(part)
} else if strings.HasPrefix(part, "q=") {
qvalue, err = strconv.ParseFloat(strings.TrimPrefix(part, "q="), 64)
if qvalue < 0.0 {
qvalue = 0.0
} else if qvalue > 1.0 {
qvalue = 1.0
}
}
}
if coding == "" {
err = fmt.Errorf("empty content-coding")
}
return
}

View file

@ -0,0 +1,72 @@
package gziphandler
import (
"bytes"
"compress/gzip"
"github.com/stretchr/testify/assert"
"io"
"net/http"
"net/http/httptest"
"testing"
)
func TestParseEncodings(t *testing.T) {
examples := map[string]codings{
// Examples from RFC 2616
"compress, gzip": codings{"compress": 1.0, "gzip": 1.0},
"": codings{},
"*": codings{"*": 1.0},
"compress;q=0.5, gzip;q=1.0": codings{"compress": 0.5, "gzip": 1.0},
"gzip;q=1.0, identity; q=0.5, *;q=0": codings{"gzip": 1.0, "identity": 0.5, "*": 0.0},
// More random stuff
"AAA;q=1": codings{"aaa": 1.0},
"BBB ; q = 2": codings{"bbb": 1.0},
}
for eg, exp := range examples {
act, _ := parseEncodings(eg)
assert.Equal(t, exp, act)
}
}
func TestGzipHandler(t *testing.T) {
testBody := "aaabbbccc"
// This just exists to provide something for GzipHandler to wrap.
handler := GzipHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
io.WriteString(w, testBody)
}))
// requests without accept-encoding are passed along as-is
req1, _ := http.NewRequest("GET", "/whatever", nil)
res1 := httptest.NewRecorder()
handler.ServeHTTP(res1, req1)
assert.Equal(t, 200, res1.Code)
assert.Equal(t, "", res1.Header().Get("Content-Encoding"))
assert.Equal(t, testBody, res1.Body.String())
// but requests with accept-encoding:gzip are compressed if possible
req2, _ := http.NewRequest("GET", "/whatever", nil)
req2.Header.Set("Accept-Encoding", "gzip")
res2 := httptest.NewRecorder()
handler.ServeHTTP(res2, req2)
assert.Equal(t, 200, res2.Code)
assert.Equal(t, "gzip", res2.Header().Get("Content-Encoding"))
assert.Equal(t, gzipStr(testBody), res2.Body.Bytes())
}
func gzipStr(s string) []byte {
var b bytes.Buffer
w := gzip.NewWriter(&b)
io.WriteString(w, s)
w.Close()
return b.Bytes()
}

View file

@ -7,7 +7,7 @@ import (
"net/http"
"time"
"github.com/thermokarst/jwt"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/thermokarst/jwt"
)
func protectMe(w http.ResponseWriter, r *http.Request) {

View file

@ -12,7 +12,7 @@ import (
"crypto/subtle"
"errors"
"fmt"
"golang.org/x/crypto/blowfish"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/golang.org/x/crypto/blowfish"
"io"
"strconv"
)

View file

@ -8,7 +8,7 @@ import (
"net/http"
"net/url"
"github.com/jmoiron/modl"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/modl"
)
var (

View file

@ -10,7 +10,7 @@ import (
"strings"
"time"
"github.com/gorilla/mux"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/gorilla/mux"
)
func handleCompare(w http.ResponseWriter, r *http.Request) *appError {

View file

@ -12,9 +12,10 @@ import (
"strings"
"time"
"github.com/gorilla/context"
"github.com/gorilla/mux"
"github.com/thermokarst/jwt"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/gorilla/context"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/gorilla/mux"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/nytimes/gziphandler"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/thermokarst/jwt"
)
var (
@ -125,7 +126,7 @@ func Handler() http.Handler {
s.Handle(route.p, j.Secure(errorHandler(route.f), verifyClaims)).Methods(route.m)
}
return jsonHandler(corsHandler(m))
return jsonHandler(gziphandler.GzipHandler(corsHandler(m)))
}
func handleGetter(g getter) errorHandler {

View file

@ -8,8 +8,8 @@ import (
"net/http"
"time"
"github.com/gorilla/context"
"github.com/lib/pq"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/gorilla/context"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq"
)
var (

14
main.go
View file

@ -8,13 +8,13 @@ import (
"os"
"sync"
"github.com/DavidHuie/gomigrate"
"github.com/codegangsta/cli"
"github.com/gorilla/schema"
"github.com/jmoiron/modl"
"github.com/jmoiron/sqlx"
"github.com/lib/pq"
"github.com/mailgun/mailgun-go"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/DavidHuie/gomigrate"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/codegangsta/cli"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/gorilla/schema"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/modl"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/sqlx"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
)
var (

View file

@ -8,7 +8,7 @@ import (
"net/http"
"net/url"
"github.com/jmoiron/modl"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/modl"
)
var (

View file

@ -9,7 +9,7 @@ import (
"net/url"
"strings"
"github.com/jmoiron/modl"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/modl"
)
var (

View file

@ -9,7 +9,7 @@ import (
"net/url"
"strings"
"github.com/jmoiron/modl"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/modl"
)
var (

View file

@ -9,7 +9,7 @@ import (
"strings"
"time"
"github.com/lib/pq"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq"
)
type NullBool struct {

View file

@ -10,11 +10,10 @@ import (
"net/url"
"regexp"
"github.com/gorilla/mux"
"github.com/lib/pq"
"github.com/mailgun/mailgun-go"
"golang.org/x/crypto/bcrypt"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/gorilla/mux"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/lib/pq"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/mailgun/mailgun-go"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/golang.org/x/crypto/bcrypt"
)
var (