This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package crypto | |
| import ( | |
| "errors" | |
| "strings" | |
| "golang.org/x/crypto/bcrypt" | |
| ) | |
| //Hash implements root.Hash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package root | |
| type Credentials struct { | |
| Username string `json:"username"` | |
| Password string `json:"password"` | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "go_web_server/pkg/crypto" | |
| "go_web_server/pkg/mongo" | |
| "go_web_server/pkg/server" | |
| "log" | |
| ) | |
| func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package server | |
| import ( | |
| "net/http" | |
| "encoding/json" | |
| ) | |
| func Error(w http.ResponseWriter, code int, message string) { | |
| Json(w, code, map[string]string{"error": message}) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package server | |
| import ( | |
| "encoding/json" | |
| "errors" | |
| "go_web_server/pkg" | |
| "log" | |
| "net/http" | |
| "github.com/gorilla/mux" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package server | |
| import ( | |
| "go_web_server/pkg" | |
| "log" | |
| "net/http" | |
| "os" | |
| "github.com/gorilla/handlers" | |
| "github.com/gorilla/mux" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package server | |
| import ( | |
| "go_rest_api/pkg" | |
| "log" | |
| "net/http" | |
| "os" | |
| "github.com/gorilla/handlers" | |
| "github.com/gorilla/mux" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ( | |
| "go_web_server/pkg/mock" | |
| ... | |
| ) | |
| ... | |
| mockHash := mock.Hash{} | |
| userService := mongo.NewUserService(session.Copy(), dbName, userCollectionName, &mockHash) | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package mongo | |
| import ( | |
| "go_web_server/pkg" | |
| "gopkg.in/mgo.v2" | |
| "gopkg.in/mgo.v2/bson" | |
| ) | |
| type UserService struct { |