handler

package
v0.0.0-...-7d02455 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BookmarksURLPrefix = "/bookmarks"
)
View Source
const DefaultLocation = "84095"

DefaultLocation is the default location to use if none is provided.

View Source
const (
	GamesURLPrefix = "/games"
)
View Source
const SecretURLPrefix = "/secrets"
View Source
const (
	UserURLPrefix = "/users"
)
View Source
const (
	WeatherURLPrefix = "/weather"
)

Variables

This section is empty.

Functions

func FileServer

func FileServer(r chi.Router, path string, root http.FileSystem)

FileServer conveniently sets up a http.FileServer handler to serve static files from a http.FileSystem.

Types

type BookmarksHandler

type BookmarksHandler struct {
}

func NewBookmarksHandler

func NewBookmarksHandler() *BookmarksHandler

func (*BookmarksHandler) ListBookmarks

func (h *BookmarksHandler) ListBookmarks(w http.ResponseWriter, r *http.Request)

func (*BookmarksHandler) RegisterRoutes

func (h *BookmarksHandler) RegisterRoutes(r chi.Router)

type CreateSecretRequest

type CreateSecretRequest struct {
	Secret string `json:"secret"`
}

type CreateUserRequest

type CreateUserRequest struct {
	Login    string `json:"login"`
	Email    string `json:"email"`
	Password string `json:"password"`
	Name     string `json:"name"`
}

func (*CreateUserRequest) Bind

func (r *CreateUserRequest) Bind(_ *http.Request) error

type GamesHandler

type GamesHandler struct {
}

func NewGamesHandler

func NewGamesHandler() *GamesHandler

func (*GamesHandler) ListGames

func (h *GamesHandler) ListGames(w http.ResponseWriter, r *http.Request)

func (*GamesHandler) RegisterRoutes

func (h *GamesHandler) RegisterRoutes(r chi.Router)

type HealthHandler

type HealthHandler struct {
}

func NewHealthHandler

func NewHealthHandler() *HealthHandler

func (*HealthHandler) GetHealth

func (h *HealthHandler) GetHealth(w http.ResponseWriter, r *http.Request)

GetHealth godoc @Summary Health check @Description get the current service health @Tags health @Accept json @Produce json @Success 200 {object} HealthResponse @Router /healthz [get]

func (*HealthHandler) GetReady

func (h *HealthHandler) GetReady(w http.ResponseWriter, r *http.Request)

GetHealth godoc @Summary Readiness check @Description get the current service readiness @Tags health @Accept json @Produce json @Success 200 {object} ReadyResponse @Router /readiness [get]

func (*HealthHandler) RegisterRoutes

func (h *HealthHandler) RegisterRoutes(r chi.Router)

type HealthResponse

type HealthResponse struct {
	Status string `json:"status"`
}

func (*HealthResponse) Render

func (resp *HealthResponse) Render(w http.ResponseWriter, r *http.Request) error

type ReadyResponse

type ReadyResponse struct {
	Status string `json:"status"`
}

func (*ReadyResponse) Render

func (resp *ReadyResponse) Render(w http.ResponseWriter, r *http.Request) error

type RootHandler

type RootHandler struct {
}

func NewRootHandler

func NewRootHandler() *RootHandler

func (*RootHandler) GetRoot

func (h *RootHandler) GetRoot(w http.ResponseWriter, r *http.Request)

GetRoot godoc @Summary Index @Description get the index route @Tags root @Accept json @Produce json @Success 200 {object} RootResponse @Router / [get]

func (*RootHandler) RegisterRoutes

func (h *RootHandler) RegisterRoutes(r chi.Router)

type RootResponse

type RootResponse struct {
	Message string `json:"message"`
}

func (*RootResponse) Render

func (resp *RootResponse) Render(w http.ResponseWriter, r *http.Request) error

type SecretHandler

type SecretHandler struct {
	// contains filtered or unexported fields
}

func NewSecretHandler

func NewSecretHandler(service service.SecretService) *SecretHandler

func (*SecretHandler) CreateSecret

func (h *SecretHandler) CreateSecret(w http.ResponseWriter, r *http.Request)

@Summary Create a secret @Description Create a secret @Router /secrets [post] @Tags secrets @Accept json @Produce json @Param secret body CreateSecretRequest true "Secret" @Success 200 {object} map[string]string

func (*SecretHandler) RegisterRoutes

func (h *SecretHandler) RegisterRoutes(r chi.Router)

func (*SecretHandler) RetrieveSecret

func (h *SecretHandler) RetrieveSecret(w http.ResponseWriter, r *http.Request)

@Summary Retrieve a secret @Description Retrieve a secret @Router /secrets/{secretId} [get] @Tags secrets @Accept json @Produce json @Param secretId path string true "Secret ID" @Success 200 {object} map[string]string

type TimeHandler

type TimeHandler struct {
}

func NewTimeHandler

func NewTimeHandler() *TimeHandler

func (*TimeHandler) CurrentTime

func (h *TimeHandler) CurrentTime(w http.ResponseWriter, r *http.Request)

GetTime godoc @Summary Get the current time @Description Get the current time @Tags time @Accept json @Produce json @Success 200 {object} TimeResponse @Router /time [get]

func (*TimeHandler) RegisterRoutes

func (h *TimeHandler) RegisterRoutes(r chi.Router)

type TimeResponse

type TimeResponse struct {
	CurrentTime string `json:"currentTime"`
}

func (*TimeResponse) Render

func (resp *TimeResponse) Render(w http.ResponseWriter, r *http.Request) error

type UsersHandler

type UsersHandler struct {
	// contains filtered or unexported fields
}

func NewUsersHandler

func NewUsersHandler(service service.UserService) *UsersHandler

func (*UsersHandler) CreateUser

func (h *UsersHandler) CreateUser(w http.ResponseWriter, r *http.Request)

CreateUser godoc @Summary Create a user @Description Create a user @Tags users @Accept json @Produce json @Param user body CreateUserRequest true "User object" @Success 201 {object} model.User @Router /users [post]

func (*UsersHandler) DeleteUser

func (h *UsersHandler) DeleteUser(w http.ResponseWriter, r *http.Request)

DeleteUser godoc @Summary Delete a user @Description Delete a user @Tags users @Accept json @Produce json @Param id path string true "User ID" @Success 204 @Router /users/{id} [delete]

func (*UsersHandler) GetUser

func (h *UsersHandler) GetUser(w http.ResponseWriter, r *http.Request)

GetUser godoc @Summary Get a user @Description Get a user @Tags users @Accept json @Produce json @Param id path string true "User ID" @Success 200 {object} model.User @Router /users/{id} [get]

func (*UsersHandler) ListUsers

func (h *UsersHandler) ListUsers(w http.ResponseWriter, r *http.Request)

ListUsers godoc @Summary List users @Description List users @Tags users @Accept json @Produce json @Success 200 {array} model.User @Router /users [get]

func (*UsersHandler) RegisterRoutes

func (h *UsersHandler) RegisterRoutes(r chi.Router)

func (*UsersHandler) UpdateUser

func (h *UsersHandler) UpdateUser(w http.ResponseWriter, r *http.Request)

UpdateUser godoc @Summary Update a user @Description Update a user @Tags users @Accept json @Produce json @Param id path string true "User ID" @Param user body model.User true "User object" @Success 200 {object} model.User @Router /users/{id} [put]

type WeatherHandler

type WeatherHandler struct {
	// contains filtered or unexported fields
}

func NewWeatherHandler

func NewWeatherHandler(service service.WeatherService) *WeatherHandler

func (*WeatherHandler) GetWeather

func (h *WeatherHandler) GetWeather(w http.ResponseWriter, r *http.Request)

@Summary Get the current weather @Description Get the current weather @Router /weater [get] @Tags weather @Accept json @Produce json @Param location query string false "Location Name" @Success 200 {object} model.Weather

func (*WeatherHandler) RegisterRoutes

func (h *WeatherHandler) RegisterRoutes(r chi.Router)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL