httpserver

package
v0.0.0-...-f2d9cf0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const RequestContextApiMethod = "requestContextApiMethod"
View Source
const RequestContextApiVersion = "requestContextApiVersion"
View Source
const RequestContextId = "requestContextId"
View Source
const RequestContextTimestamp = "requestContextTimestamp"

Variables

This section is empty.

Functions

func HealthCheck

func HealthCheck(w http.ResponseWriter, r *http.Request)

func HelloWorld

func HelloWorld(w http.ResponseWriter, r *http.Request)

func NewRequestContextId

func NewRequestContextId(r *http.Request) (*http.Request, string)

func SetApiRequestContext

func SetApiRequestContext(r *http.Request, version string, method string) *http.Request

func WriteEmptyResponse

func WriteEmptyResponse(w http.ResponseWriter, r *http.Request)

func WriteErrorResponse

func WriteErrorResponse(w http.ResponseWriter, r *http.Request)

func WriteResponse

func WriteResponse(w http.ResponseWriter, r *http.Request, response Response)

WriteResponse TODO Separate request validation from here TODO Separate header configuration from here

Types

type DataProviderDataResponse

type DataProviderDataResponse struct {
	Status  *int        `json:"-"`
	Message *string     `json:"-"`
	Data    interface{} `json:"data,omitempty"`
	Total   *int        `json:"total,omitempty"`
}

type DataProviderErrorResponse

type DataProviderErrorResponse struct {
	Status  *int    `json:"status,omitempty"`
	Message *string `json:"message,omitempty"`
}

type DataResponse

type DataResponse struct {
	Code    *int        `json:"code,omitempty"`
	Message *string     `json:"message,omitempty"`
	Items   interface{} `json:"items,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Code    *int    `json:"code,omitempty"`
	Message *string `json:"message,omitempty"`
}

type HttpServer

type HttpServer struct {
	Port int
	DB   data.DB
}

func NewHttpServer

func NewHttpServer(port int) (HttpServer, error)

func (*HttpServer) AddRouterUsersV1

func (p *HttpServer) AddRouterUsersV1(router *mux.Router)

func (*HttpServer) CreateUserV1

func (p *HttpServer) CreateUserV1(w http.ResponseWriter, r *http.Request)

func (*HttpServer) Defer

func (p *HttpServer) Defer()

func (*HttpServer) DeleteUserByUUIDV1

func (p *HttpServer) DeleteUserByUUIDV1(w http.ResponseWriter, r *http.Request)

func (*HttpServer) FindAllUsersV1

func (p *HttpServer) FindAllUsersV1(w http.ResponseWriter, r *http.Request)

func (*HttpServer) FindUserByUUIDV1

func (p *HttpServer) FindUserByUUIDV1(w http.ResponseWriter, r *http.Request)

func (*HttpServer) ListenAndServe

func (p *HttpServer) ListenAndServe() error

func (*HttpServer) NewRouter

func (p *HttpServer) NewRouter() *mux.Router

func (*HttpServer) UpdateUserV1

func (p *HttpServer) UpdateUserV1(w http.ResponseWriter, r *http.Request)

type Response

type Response struct {
	ApiVersion *string        `json:"version,omitempty"`
	Id         *string        `json:"id,omitempty"`
	Method     *string        `json:"method,omitempty"`
	Data       *DataResponse  `json:"data,omitempty"`
	Error      *ErrorResponse `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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