Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/chidiwilliams/go-web-server-tips
/ functions
Functions
39 in github.com/chidiwilliams/go-web-server-tips
⨍
Functions
39
◇
Types & classes
16
↓ 4 callers
Method
ToJSON
ToJSON writes the response to the given http.ResponseWriter with an application/json Content-Type header.
server/responses/response.go:21
↓ 3 callers
Function
fatalIfErr
(err error)
server/server.go:50
↓ 2 callers
Function
Error
Error returns an AppError with a TypeBadRequest type.
errors/error.go:31
↓ 2 callers
Method
Error
()
errors/error.go:21
↓ 2 callers
Function
Fail
Fail returns a new failed response.
server/responses/response.go:33
↓ 2 callers
Function
OK
OK returns a new successful response.
server/responses/response.go:28
↓ 2 callers
Method
bookKey
(id bson.ObjectId)
services/book/repository/inmemory.go:54
↓ 2 callers
Function
newResponse
(success bool, message string, data interface{}, statusCode int)
server/responses/response.go:37
↓ 1 callers
Method
CreateBook
(title string)
services/book/service.go:14
↓ 1 callers
Method
CreateBook
(w http.ResponseWriter, r *http.Request)
server/handlers/book/handler.go:16
↓ 1 callers
Function
DecodeJSON
DecodeJSON reads JSON data from reader and decodes it into the value pointed to by v.
server/decoder/decoder.go:12
↓ 1 callers
Method
GetBook
(id bson.ObjectId)
services/book/service.go:13
↓ 1 callers
Method
GetBook
(w http.ResponseWriter, r *http.Request)
server/handlers/book/handler.go:17
↓ 1 callers
Function
NewInMemoryRepository
(db *buntdb.DB)
services/book/repository/inmemory.go:13
↓ 1 callers
Function
NewMongoRepository
(db *mgo.Database)
services/book/repository/mongo.go:10
↓ 1 callers
Function
NewService
(repository repository.Repository)
services/book/service.go:17
↓ 1 callers
Function
NotFound
NotFound returns an AppError with a TypeNotFound type.
errors/error.go:39
↓ 1 callers
Function
Server
Server configures and returns a new http.Server
server/server.go:20
↓ 1 callers
Method
Type
Type returns the type of the error.
errors/error.go:26
↓ 1 callers
Function
connectToInMemoryDB
()
server/inmemory.go:7
↓ 1 callers
Function
connectToMongo
()
server/mongo.go:9
↓ 1 callers
Function
ensureMongoIndexes
(db *mgo.Database)
server/mongo.go:18
↓ 1 callers
Function
errTypeStatusCode
(errType errors2.Type)
server/handlers/handler.go:41
↓ 1 callers
Function
respondWithErr
(err error, w http.ResponseWriter)
server/handlers/handler.go:28
↓ 1 callers
Function
toSentenceCase
(s string)
server/handlers/handler.go:52
Method
CreateBook
(title string)
services/book/service.go:25
Method
CreateBook
(book models.Book)
services/book/repository/repository.go:16
Method
CreateBook
(book models.Book)
services/book/repository/mongo.go:18
Method
CreateBook
(book models.Book)
services/book/repository/inmemory.go:21
Method
CreateBook
(w http.ResponseWriter, r *http.Request)
server/handlers/book/handler.go:32
Method
GetBook
(id bson.ObjectId)
services/book/service.go:34
Method
GetBook
(id bson.ObjectId)
services/book/repository/repository.go:15
Method
GetBook
(id bson.ObjectId)
services/book/repository/mongo.go:26
Method
GetBook
(id bson.ObjectId)
services/book/repository/inmemory.go:33
Method
GetBook
(w http.ResponseWriter, r *http.Request)
server/handlers/book/handler.go:46
Function
NewBookHandler
(bookService book.Service)
server/handlers/book/handler.go:20
Method
ServeHTTP
(w http.ResponseWriter, r *http.Request)
server/handlers/handler.go:17
Function
init
()
server/server.go:30
Function
main
()
main.go:9