Documentation
¶
Index ¶
- Variables
- func GetCategoryPersistence(ctx context.Context) persistence.Persistencer[Category]
- func GetPostPersistence(ctx context.Context) persistence.Persistencer[Post]
- func HandleDeletePost(ctx context.Context, w http.ResponseWriter, r *http.Request) error
- func HandleMethodNotAllowed(ctx context.Context, r *http.Request)
- func HandleNotFound(w http.ResponseWriter, r *http.Request)
- func HandleRenderHome(w http.ResponseWriter, r *http.Request) error
- func HandleRenderPost(w http.ResponseWriter, r *http.Request) error
- func HandleSitemap(w http.ResponseWriter, ctx context.Context) error
- func InterceptorAccessLog(next box.H) box.H
- func NewApi(version, staticsDir string, postPersistencer persistence.Persistencer[Post], ...) http.Handler
- func PrettyError(next box.H) box.H
- type Category
- type CreateCategoryRequest
- type CreatePostRequest
- type HttpError
- type ModifyPostRequest
- type Post
- func HandleCreatePost(input *CreatePostRequest, w http.ResponseWriter, ctx context.Context) (*Post, error)
- func HandleGetPost(ctx context.Context, r *http.Request) (*Post, error)
- func HandleListPosts(w http.ResponseWriter, r *http.Request) ([]Post, error)
- func HandleModifyPost(ctx context.Context, r *http.Request, input *ModifyPostRequest) (*Post, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorPersistenceRead = HttpError{ Status: http.StatusInternalServerError, Description: "Problem reading from persistence layer", }
View Source
var ErrorPersistenceWrite = HttpError{ Status: http.StatusInternalServerError, Description: "Problem writing to persistence layer", }
View Source
var ErrorPostForbidden = HttpError{ Status: http.StatusForbidden, Description: "You are not authorized to perform this action for this post", }
View Source
var ErrorPostNotFound = HttpError{ Status: http.StatusNotFound, Description: "Post not found", }
Functions ¶
func GetCategoryPersistence ¶ added in v0.0.2
func GetCategoryPersistence(ctx context.Context) persistence.Persistencer[Category]
GetCategoryPersistence from context (where categories are stored)
func GetPostPersistence ¶ added in v0.0.2
func GetPostPersistence(ctx context.Context) persistence.Persistencer[Post]
GetPostPersistence from context (where posts are stored)
func HandleDeletePost ¶ added in v0.0.2
func HandleMethodNotAllowed ¶ added in v0.0.2
func HandleNotFound ¶
func HandleNotFound(w http.ResponseWriter, r *http.Request)
func HandleRenderHome ¶ added in v0.0.2
func HandleRenderHome(w http.ResponseWriter, r *http.Request) error
func HandleRenderPost ¶ added in v0.0.2
func HandleRenderPost(w http.ResponseWriter, r *http.Request) error
func HandleSitemap ¶ added in v0.0.2
func HandleSitemap(w http.ResponseWriter, ctx context.Context) error
func NewApi ¶
func NewApi( version, staticsDir string, postPersistencer persistence.Persistencer[Post], categoryPersistencer persistence.Persistencer[Category], log *slog.Logger, ) http.Handler
Types ¶
type Category ¶ added in v0.0.2
type Category struct {
Id string `json:"id"`
Name string `json:"name"`
CreationTime time.Time `json:"creation_time"`
ModificationTime time.Time `json:"modification_time"`
}
func HandleCreateCategory ¶ added in v0.0.2
func HandleCreateCategory(input *CreateCategoryRequest, w http.ResponseWriter, ctx context.Context) (*Category, error)
type CreateCategoryRequest ¶ added in v0.0.2
type CreateCategoryRequest struct {
Name string `json:"name"`
}
type CreatePostRequest ¶ added in v0.0.2
type HttpError ¶ added in v0.0.2
type ModifyPostRequest ¶ added in v0.0.2
type Post ¶ added in v0.0.2
type Post struct {
Id string `json:"id"`
Author auth.User `json:"author"`
Title string `json:"title"`
Body string `json:"body"`
CreationTime time.Time `json:"creation_time"`
ModificationTime time.Time `json:"modification_time"`
}
func HandleCreatePost ¶ added in v0.0.2
func HandleCreatePost(input *CreatePostRequest, w http.ResponseWriter, ctx context.Context) (*Post, error)
func HandleGetPost ¶ added in v0.0.2
func HandleListPosts ¶ added in v0.0.2
func HandleModifyPost ¶ added in v0.0.2
Source Files
¶
- api.go
- api_errors.go
- api_helpers.go
- build_openapi.go
- handle_createCategory.go
- handle_createPost.go
- handle_deletePost.go
- handle_getPost.go
- handle_listPosts.go
- handle_method_not_allowed.go
- handle_modifyPost.go
- handle_not_found.go
- handle_renderHome.go
- handle_renderPost.go
- handle_sitemap.go
- http_error.go
- interceptor_access_log.go
- interceptor_pretty_error.go
- model_category.go
- model_post.go
- render_helpers.go
Click to show internal directories.
Click to hide internal directories.