Skip to content

Commit

Permalink
renaming files as per conventions discussed in #309
Browse files Browse the repository at this point in the history
  • Loading branch information
quii committed Jun 18, 2020
1 parent 746cc38 commit 31ce9f7
Show file tree
Hide file tree
Showing 71 changed files with 8 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions q-and-a/http-handlers-revisited/still_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,27 @@ import (
"net/http"
)

// User represents a person in our system
type User struct {
Name string
}

// UserService provides ways of working with users
type UserService interface {
Register(user User) (insertedID string, err error)
}

// UserServer provides a HTTP API for working with users
type UserServer struct {
service UserService
}

// NewUserServer creates a UserServer
func NewUserServer(service UserService) *UserServer {
return &UserServer{service: service}
}

// RegisterUser is a http handler for storing users
func (u *UserServer) RegisterUser(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()

Expand All @@ -45,15 +50,18 @@ func (u *UserServer) RegisterUser(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, insertedID)
}

// MongoUserService provides storage functionality for Users
type MongoUserService struct {
}

// NewMongoUserService creates a new MongoUserService managing connection pools etc probably!
func NewMongoUserService() *MongoUserService {
//todo: pass in DB URL as argument to this function
//todo: connect to db, create a connection pool
return &MongoUserService{}
}

// Register will store a user in mongo
func (m MongoUserService) Register(user User) (insertedID string, err error) {
// use m.mongoConnection to perform queries
panic("implement me")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 31ce9f7

Please sign in to comment.