Skip to content

Instantly share code, notes, and snippets.

package crypto
import (
"errors"
"strings"
"golang.org/x/crypto/bcrypt"
)
//Hash implements root.Hash
@eamonnmcevoy
eamonnmcevoy / credentials.go
Last active February 5, 2018 23:04
login endpoint
package root
type Credentials struct {
Username string `json:"username"`
Password string `json:"password"`
}
package main
import (
"go_web_server/pkg/crypto"
"go_web_server/pkg/mongo"
"go_web_server/pkg/server"
"log"
)
func main() {
package server
import (
"net/http"
"encoding/json"
)
func Error(w http.ResponseWriter, code int, message string) {
Json(w, code, map[string]string{"error": message})
}
package server
import (
"encoding/json"
"errors"
"go_web_server/pkg"
"log"
"net/http"
"github.com/gorilla/mux"
package server
import (
"go_web_server/pkg"
"log"
"net/http"
"os"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
package server
import (
"go_rest_api/pkg"
"log"
"net/http"
"os"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
import (
"go_web_server/pkg/mock"
...
)
...
mockHash := mock.Hash{}
userService := mongo.NewUserService(session.Copy(), dbName, userCollectionName, &mockHash)
...
@eamonnmcevoy
eamonnmcevoy / hash.go
Created April 15, 2017 06:57
simple hash mock
package mock
type Hash struct{}
func (h *Hash) Generate(s string) (string, error) {
return s, nil
}
func (h *Hash) Compare(hash string, s string) error {
return nil
package mongo
import (
"go_web_server/pkg"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
type UserService struct {