Documentation ¶
Overview ¶
Package api provides primitives to interact with the openapi HTTP API.
Code generated by github.com/discord-gophers/goapi-gen version (devel) DO NOT EDIT.
Index ¶
- func GetSwagger() (swagger *openapi3.T, err error)
- func Handler(si ServerInterface, opts ...ServerOption) http.Handler
- func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)
- type InvalidParamFormatError
- type Login
- type ParameterError
- type Post
- type PostAuthLoginJSONBody
- type PostAuthLoginJSONRequestBody
- type PostAuthSignupJSONBody
- type PostAuthSignupJSONRequestBody
- type PostPostsJSONBody
- type PostPostsJSONRequestBody
- type PutPostsPostIDJSONBody
- type PutPostsPostIDJSONRequestBody
- type RequiredHeaderError
- type RequiredParamError
- type Response
- func GetPostsJSON200Response(body []Post) *Response
- func GetPostsPostIDJSON200Response(body Post) *Response
- func PostAuthLoginJSON200Response(body User) *Response
- func PostAuthSignupJSON201Response(body User) *Response
- func PostPostsJSON201Response(body Post) *Response
- func PutPostsPostIDJSON200Response(body Post) *Response
- func (resp *Response) ContentType(contentType string) *Response
- func (resp *Response) MarshalJSON() ([]byte, error)
- func (resp *Response) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (resp *Response) Render(w http.ResponseWriter, r *http.Request) error
- func (resp *Response) Status(code int) *Response
- type Server
- func (s *Server) Authentication(next http.Handler) http.Handler
- func (s *Server) DeletePostsPostID(w http.ResponseWriter, r *http.Request, postID uuid.UUID) *Response
- func (s *Server) GetPosts(w http.ResponseWriter, r *http.Request) *Response
- func (s *Server) GetPostsPostID(w http.ResponseWriter, r *http.Request, postID uuid.UUID) *Response
- func (s *Server) PostAuthLogin(w http.ResponseWriter, r *http.Request) *Response
- func (s *Server) PostAuthLogout(w http.ResponseWriter, r *http.Request) *Response
- func (s *Server) PostAuthSignup(w http.ResponseWriter, r *http.Request) *Response
- func (s *Server) PostPosts(w http.ResponseWriter, r *http.Request) *Response
- func (s *Server) PutPostsPostID(w http.ResponseWriter, r *http.Request, postID uuid.UUID) *Response
- func (s *Server) Start(c config.Server, wg *sync.WaitGroup) error
- func (s *Server) Stop()
- type ServerInterface
- type ServerInterfaceWrapper
- func (siw *ServerInterfaceWrapper) DeletePostsPostID(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetPosts(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetPostsPostID(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostAuthLogin(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostAuthLogout(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostAuthSignup(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostPosts(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PutPostsPostID(w http.ResponseWriter, r *http.Request)
- type ServerOption
- func WithErrorHandler(handler func(w http.ResponseWriter, r *http.Request, err error)) ServerOption
- func WithMiddleware(key string, middleware func(http.Handler) http.Handler) ServerOption
- func WithMiddlewares(middlewares map[string]func(http.Handler) http.Handler) ServerOption
- func WithRouter(r chi.Router) ServerOption
- func WithServerBaseURL(url string) ServerOption
- type ServerOptions
- type Signup
- type TooManyValuesForParamError
- type UnescapedCookieParamError
- type UnmarshalingParamError
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSwagger ¶
GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.
func Handler ¶
func Handler(si ServerInterface, opts ...ServerOption) http.Handler
Handler creates http.Handler with routing matching OpenAPI spec.
Types ¶
type InvalidParamFormatError ¶
type InvalidParamFormatError struct {
// contains filtered or unexported fields
}
func (InvalidParamFormatError) Error ¶
func (err InvalidParamFormatError) Error() string
Error implements error.
func (InvalidParamFormatError) ParamName ¶
func (err InvalidParamFormatError) ParamName() string
func (InvalidParamFormatError) Unwrap ¶
func (err InvalidParamFormatError) Unwrap() error
type Login ¶
type Login struct { // The user's email address Email openapi_types.Email `json:"email"` // The user's password Password string `json:"password"` }
Login defines model for Login.
type ParameterError ¶
type ParameterError interface { error // ParamName is the name of the parameter that the error is referring to. ParamName() string }
ParameterName is an interface that is implemented by error types that are relevant to a specific parameter.
type Post ¶
type Post struct { // The content of the blog post in markdown format Content string `json:"content"` // The date and time the blog post was created CreatedAt time.Time `json:"createdAt"` // The unique identifier of the blog post ID uuid.UUID `json:"id"` // The title of the blog post Title string `json:"title"` // The date and time the blog post was last updated UpdatedAt time.Time `json:"updatedAt"` }
Post defines model for Post.
type PostAuthLoginJSONBody ¶
type PostAuthLoginJSONBody Login
PostAuthLoginJSONBody defines parameters for PostAuthLogin.
type PostAuthLoginJSONRequestBody ¶
type PostAuthLoginJSONRequestBody PostAuthLoginJSONBody
PostAuthLoginJSONRequestBody defines body for PostAuthLogin for application/json ContentType.
type PostAuthSignupJSONBody ¶
type PostAuthSignupJSONBody Signup
PostAuthSignupJSONBody defines parameters for PostAuthSignup.
type PostAuthSignupJSONRequestBody ¶
type PostAuthSignupJSONRequestBody PostAuthSignupJSONBody
PostAuthSignupJSONRequestBody defines body for PostAuthSignup for application/json ContentType.
type PostPostsJSONBody ¶
type PostPostsJSONBody Post
PostPostsJSONBody defines parameters for PostPosts.
type PostPostsJSONRequestBody ¶
type PostPostsJSONRequestBody PostPostsJSONBody
PostPostsJSONRequestBody defines body for PostPosts for application/json ContentType.
type PutPostsPostIDJSONBody ¶
type PutPostsPostIDJSONBody Post
PutPostsPostIDJSONBody defines parameters for PutPostsPostID.
type PutPostsPostIDJSONRequestBody ¶
type PutPostsPostIDJSONRequestBody PutPostsPostIDJSONBody
PutPostsPostIDJSONRequestBody defines body for PutPostsPostID for application/json ContentType.
type RequiredHeaderError ¶
type RequiredHeaderError struct {
// contains filtered or unexported fields
}
func (RequiredHeaderError) Error ¶
func (err RequiredHeaderError) Error() string
Error implements error.
func (RequiredHeaderError) ParamName ¶
func (err RequiredHeaderError) ParamName() string
type RequiredParamError ¶
type RequiredParamError struct {
// contains filtered or unexported fields
}
func (RequiredParamError) Error ¶
func (err RequiredParamError) Error() string
Error implements error.
func (RequiredParamError) ParamName ¶
func (err RequiredParamError) ParamName() string
func (RequiredParamError) Unwrap ¶
func (err RequiredParamError) Unwrap() error
type Response ¶
type Response struct { Code int // contains filtered or unexported fields }
Response is a common response struct for all the API calls. A Response object may be instantiated via functions for specific operation responses. It may also be instantiated directly, for the purpose of responding with a single status code.
func GetPostsJSON200Response ¶
GetPostsJSON200Response is a constructor method for a GetPosts response. A *Response is returned with the configured status code and content type from the spec.
func GetPostsPostIDJSON200Response ¶
GetPostsPostIDJSON200Response is a constructor method for a GetPostsPostID response. A *Response is returned with the configured status code and content type from the spec.
func PostAuthLoginJSON200Response ¶
PostAuthLoginJSON200Response is a constructor method for a PostAuthLogin response. A *Response is returned with the configured status code and content type from the spec.
func PostAuthSignupJSON201Response ¶
PostAuthSignupJSON201Response is a constructor method for a PostAuthSignup response. A *Response is returned with the configured status code and content type from the spec.
func PostPostsJSON201Response ¶
PostPostsJSON201Response is a constructor method for a PostPosts response. A *Response is returned with the configured status code and content type from the spec.
func PutPostsPostIDJSON200Response ¶
PutPostsPostIDJSON200Response is a constructor method for a PutPostsPostID response. A *Response is returned with the configured status code and content type from the spec.
func (*Response) ContentType ¶
ContentType is a builder method to override the default content type for a response.
func (*Response) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface. This is used to only marshal the body of the response.
func (*Response) MarshalXML ¶
MarshalXML implements the xml.Marshaler interface. This is used to only marshal the body of the response.
type Server ¶
type Server struct { DB db.Querier Log zerolog.Logger Server http.Server Sessions *scs.SessionManager }
func (*Server) DeletePostsPostID ¶
func (*Server) GetPostsPostID ¶
func (*Server) PostAuthLogin ¶
func (*Server) PostAuthLogout ¶
func (*Server) PostAuthSignup ¶
func (*Server) PutPostsPostID ¶
type ServerInterface ¶
type ServerInterface interface { // Log in // (POST /auth/login) PostAuthLogin(w http.ResponseWriter, r *http.Request) *Response // Log out // (POST /auth/logout) PostAuthLogout(w http.ResponseWriter, r *http.Request) *Response // Sign up // (POST /auth/signup) PostAuthSignup(w http.ResponseWriter, r *http.Request) *Response // Get all blog posts // (GET /posts) GetPosts(w http.ResponseWriter, r *http.Request) *Response // Create a new blog post // (POST /posts) PostPosts(w http.ResponseWriter, r *http.Request) *Response // Delete a blog post // (DELETE /posts/{postId}) DeletePostsPostID(w http.ResponseWriter, r *http.Request, postID uuid.UUID) *Response // Get a specific blog post // (GET /posts/{postId}) GetPostsPostID(w http.ResponseWriter, r *http.Request, postID uuid.UUID) *Response // Update a blog post // (PUT /posts/{postId}) PutPostsPostID(w http.ResponseWriter, r *http.Request, postID uuid.UUID) *Response }
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct { Handler ServerInterface Middlewares map[string]func(http.Handler) http.Handler ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) }
ServerInterfaceWrapper converts contexts to parameters.
func (*ServerInterfaceWrapper) DeletePostsPostID ¶
func (siw *ServerInterfaceWrapper) DeletePostsPostID(w http.ResponseWriter, r *http.Request)
DeletePostsPostID operation middleware
func (*ServerInterfaceWrapper) GetPosts ¶
func (siw *ServerInterfaceWrapper) GetPosts(w http.ResponseWriter, r *http.Request)
GetPosts operation middleware
func (*ServerInterfaceWrapper) GetPostsPostID ¶
func (siw *ServerInterfaceWrapper) GetPostsPostID(w http.ResponseWriter, r *http.Request)
GetPostsPostID operation middleware
func (*ServerInterfaceWrapper) PostAuthLogin ¶
func (siw *ServerInterfaceWrapper) PostAuthLogin(w http.ResponseWriter, r *http.Request)
PostAuthLogin operation middleware
func (*ServerInterfaceWrapper) PostAuthLogout ¶
func (siw *ServerInterfaceWrapper) PostAuthLogout(w http.ResponseWriter, r *http.Request)
PostAuthLogout operation middleware
func (*ServerInterfaceWrapper) PostAuthSignup ¶
func (siw *ServerInterfaceWrapper) PostAuthSignup(w http.ResponseWriter, r *http.Request)
PostAuthSignup operation middleware
func (*ServerInterfaceWrapper) PostPosts ¶
func (siw *ServerInterfaceWrapper) PostPosts(w http.ResponseWriter, r *http.Request)
PostPosts operation middleware
func (*ServerInterfaceWrapper) PutPostsPostID ¶
func (siw *ServerInterfaceWrapper) PutPostsPostID(w http.ResponseWriter, r *http.Request)
PutPostsPostID operation middleware
type ServerOption ¶
type ServerOption func(*ServerOptions)
func WithErrorHandler ¶
func WithErrorHandler(handler func(w http.ResponseWriter, r *http.Request, err error)) ServerOption
func WithMiddleware ¶
func WithMiddlewares ¶
func WithRouter ¶
func WithRouter(r chi.Router) ServerOption
func WithServerBaseURL ¶
func WithServerBaseURL(url string) ServerOption
type ServerOptions ¶
type Signup ¶
type Signup struct { // The user's email address Email openapi_types.Email `json:"email"` // The user's password Password string `json:"password"` // The user's username Username string `json:"username"` }
Signup defines model for Signup.
type TooManyValuesForParamError ¶
type TooManyValuesForParamError struct { NumValues int // contains filtered or unexported fields }
func (TooManyValuesForParamError) Error ¶
func (err TooManyValuesForParamError) Error() string
Error implements error.
func (TooManyValuesForParamError) ParamName ¶
func (err TooManyValuesForParamError) ParamName() string
type UnescapedCookieParamError ¶
type UnescapedCookieParamError struct {
// contains filtered or unexported fields
}
func (UnescapedCookieParamError) Error ¶
func (err UnescapedCookieParamError) Error() string
Error implements error.
func (UnescapedCookieParamError) ParamName ¶
func (err UnescapedCookieParamError) ParamName() string
func (UnescapedCookieParamError) Unwrap ¶
func (err UnescapedCookieParamError) Unwrap() error
type UnmarshalingParamError ¶
type UnmarshalingParamError struct {
// contains filtered or unexported fields
}
func (UnmarshalingParamError) Error ¶
func (err UnmarshalingParamError) Error() string
Error implements error.
func (UnmarshalingParamError) ParamName ¶
func (err UnmarshalingParamError) ParamName() string
func (UnmarshalingParamError) Unwrap ¶
func (err UnmarshalingParamError) Unwrap() error