Documentation ¶
Overview ¶
Package rest provides primitives to interact with the openapi HTTP API.
Code generated by unknown module path version unknown version DO NOT EDIT.
Index ¶
- Constants
- Variables
- func CustomSchemaErrorFunc(err *openapi3.SchemaError) string
- func ReadOpenAPI(path string) (*openapi3.T, error)
- func RegisterHandlers(router gin.IRouter, si ServerInterface)
- func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options GinServerOptions)
- func Run(env, specPath, rolePolicyPath, scopePolicyPath string) (<-chan error, error)
- func SSEHeadersMiddleware() gin.HandlerFunc
- func ValidateRequestFromContext(c *gin.Context, router routers.Router, options *OAValidatorOptions) error
- type AuthRestriction
- type ClientChan
- type Config
- type DemoTwoWorkItemCreateRequest
- type DemoTwoWorkItemsResponse
- type DemoWorkItemCreateRequest
- type DemoWorkItemsResponse
- type ErrorHandler
- type Event
- type GinServerOptions
- type Handlers
- func (h *Handlers) AdminPing(c *gin.Context)
- func (h *Handlers) CreateWorkitem(c *gin.Context)
- func (h *Handlers) CreateWorkitemComment(c *gin.Context, id int)
- func (h *Handlers) CreateWorkitemTag(c *gin.Context, project models.Project)
- func (h *Handlers) DeleteUser(c *gin.Context, id uuid.UUID)
- func (h *Handlers) DeleteWorkitem(c *gin.Context, id int)
- func (h *Handlers) Events(c *gin.Context, params models.EventsParams)
- func (h *Handlers) GetCurrentUser(c *gin.Context)
- func (h *Handlers) GetProject(c *gin.Context, project models.Project)
- func (h *Handlers) GetProjectBoard(c *gin.Context, project models.Project)
- func (h *Handlers) GetProjectConfig(c *gin.Context, project models.Project)
- func (h *Handlers) GetProjectWorkitems(c *gin.Context, project models.Project, ...)
- func (h *Handlers) GetWorkitem(c *gin.Context, id int)
- func (h *Handlers) InitializeProject(c *gin.Context, project models.Project)
- func (h *Handlers) MyProviderCallback(c *gin.Context)
- func (h *Handlers) MyProviderLogin(c *gin.Context)
- func (h *Handlers) OpenapiYamlGet(c *gin.Context)
- func (h *Handlers) Ping(c *gin.Context)
- func (h *Handlers) UpdateProjectConfig(c *gin.Context, project models.Project)
- func (h *Handlers) UpdateUser(c *gin.Context, id uuid.UUID)
- func (h *Handlers) UpdateUserAuthorization(c *gin.Context, id uuid.UUID)
- func (h *Handlers) UpdateWorkitem(c *gin.Context, id int)
- type MiddlewareFunc
- type MultiErrorHandler
- type OAValidatorOptions
- type OperationID
- type ProjectBoardCreateRequest
- type ProjectBoardResponse
- type ProjectName
- type PubSub
- type Server
- type ServerInterface
- type ServerInterfaceWrapper
- func (siw *ServerInterfaceWrapper) AdminPing(c *gin.Context)
- func (siw *ServerInterfaceWrapper) CreateWorkitem(c *gin.Context)
- func (siw *ServerInterfaceWrapper) CreateWorkitemComment(c *gin.Context)
- func (siw *ServerInterfaceWrapper) CreateWorkitemTag(c *gin.Context)
- func (siw *ServerInterfaceWrapper) DeleteUser(c *gin.Context)
- func (siw *ServerInterfaceWrapper) DeleteWorkitem(c *gin.Context)
- func (siw *ServerInterfaceWrapper) Events(c *gin.Context)
- func (siw *ServerInterfaceWrapper) GetCurrentUser(c *gin.Context)
- func (siw *ServerInterfaceWrapper) GetProject(c *gin.Context)
- func (siw *ServerInterfaceWrapper) GetProjectBoard(c *gin.Context)
- func (siw *ServerInterfaceWrapper) GetProjectConfig(c *gin.Context)
- func (siw *ServerInterfaceWrapper) GetProjectWorkitems(c *gin.Context)
- func (siw *ServerInterfaceWrapper) GetWorkitem(c *gin.Context)
- func (siw *ServerInterfaceWrapper) InitializeProject(c *gin.Context)
- func (siw *ServerInterfaceWrapper) MyProviderCallback(c *gin.Context)
- func (siw *ServerInterfaceWrapper) MyProviderLogin(c *gin.Context)
- func (siw *ServerInterfaceWrapper) OpenapiYamlGet(c *gin.Context)
- func (siw *ServerInterfaceWrapper) Ping(c *gin.Context)
- func (siw *ServerInterfaceWrapper) UpdateProjectConfig(c *gin.Context)
- func (siw *ServerInterfaceWrapper) UpdateUser(c *gin.Context)
- func (siw *ServerInterfaceWrapper) UpdateUserAuthorization(c *gin.Context)
- func (siw *ServerInterfaceWrapper) UpdateWorkitem(c *gin.Context)
- type ServerOption
- type SharedWorkItemFields
- type TeamCreateRequest
- type TeamUpdateRequest
- type User
- type UserNotificationsChan
- type WorkItemCommentCreateRequest
- type WorkItemResponse
- type WorkItemTagCreateRequest
Constants ¶
const OtelName = "github.com/danicc097/openapi-go-gin-postgres-sqlc/internal/rest"
const ValidationErrorSeparator = "$$$$"
Variables ¶
var Alphanumspace validator.Func = func(fl validator.FieldLevel) bool {
return alphanumSpaceRegex.MatchString(fl.Field().String())
}
Functions ¶
func CustomSchemaErrorFunc ¶
func CustomSchemaErrorFunc(err *openapi3.SchemaError) string
func ReadOpenAPI ¶
ReadOpenAPI parses and validates an OpenAPI spec by filename and returns it.
func RegisterHandlers ¶
func RegisterHandlers(router gin.IRouter, si ServerInterface)
RegisterHandlers creates http.Handler with routing matching OpenAPI spec.
func RegisterHandlersWithOptions ¶
func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options GinServerOptions)
RegisterHandlersWithOptions creates http.Handler with additional options
func Run ¶
Run configures a server and underlying services with the given configuration. NewServer takes its own config as is now.
func SSEHeadersMiddleware ¶
func SSEHeadersMiddleware() gin.HandlerFunc
func ValidateRequestFromContext ¶
func ValidateRequestFromContext(c *gin.Context, router routers.Router, options *OAValidatorOptions) error
ValidateRequestFromContext is called from the middleware above and actually does the work of validating a request.
Types ¶
type AuthRestriction ¶
type ClientChan ¶
type ClientChan chan string
New event messages are broadcasted to all registered client connection channels.
type Config ¶
type Config struct { // Port to listen to. Use ":0" for a random port. Address string Pool *pgxpool.Pool SQLPool *sql.DB Redis *rv8.Client Logger *zap.SugaredLogger // SpecPath is the OpenAPI spec filepath. SpecPath string MovieSvcClient v1.MovieGenreClient ScopePolicyPath string RolePolicyPath string MyProviderCallbackPath string }
type DemoTwoWorkItemCreateRequest ¶
type DemoTwoWorkItemCreateRequest struct { ProjectName services.DemoTwoWorkItemCreateParams }
type DemoTwoWorkItemsResponse ¶
type DemoTwoWorkItemsResponse struct { db.WorkItem DemoTwoWorkItem db.DemoTwoWorkItem `json:"demoTwoWorkItem" required:"true"` }
DemoTwoWorkItemsResponse represents an OpenAPI schema response for a ProjectBoard.
type DemoWorkItemCreateRequest ¶
type DemoWorkItemCreateRequest struct { ProjectName services.DemoWorkItemCreateParams }
type DemoWorkItemsResponse ¶
type DemoWorkItemsResponse struct { db.WorkItem DemoWorkItem db.DemoWorkItem `json:"demoWorkItem" required:"true"` }
DemoWorkItemsResponse represents an OpenAPI schema response for a ProjectBoard.
type ErrorHandler ¶
ErrorHandler is called when there is an error in validation.
type Event ¶
type Event struct { // Events are pushed to this channel by the main events-gathering routine Message chan string Message2 chan string // New client connections NewClients chan chan string NewClients2 chan chan string // Closed client connections ClosedClients chan chan string // Total client connections ClientsForMessage1 map[chan string]struct{} ClientsForMessage2 map[chan string]struct{} }
It keeps a list of clients those are currently attached and broadcasting events to those clients.
type GinServerOptions ¶
type GinServerOptions struct {
BaseURL string
}
GinServerOptions provides options for the Gin server.
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers implements ServerInterface.
func NewHandlers ¶
func NewHandlers( logger *zap.SugaredLogger, pool *pgxpool.Pool, moviesvcclient v1.MovieGenreClient, specPath string, usvc *services.User, demoworkitemsvc *services.DemoWorkItem, demotwoworkitemsvc *services.DemoTwoWorkItem, workitemtagsvc *services.WorkItemTag, authzsvc *services.Authorization, authnsvc *services.Authentication, authmw *authMiddleware, provider rp.RelyingParty, ) *Handlers
NewHandlers returns an server implementation of an openapi specification.
func (*Handlers) CreateWorkitem ¶
create workitem.
func (*Handlers) CreateWorkitemComment ¶
create workitem comment.
func (*Handlers) CreateWorkitemTag ¶
func (*Handlers) DeleteUser ¶
DeleteUser deletes the user by id.
func (*Handlers) DeleteWorkitem ¶
delete workitem.
func (*Handlers) Events ¶
func (h *Handlers) Events(c *gin.Context, params models.EventsParams)
Events represents server events. TODO requires query param projectId=... to subscribe to the current project's topics only.
func (*Handlers) GetCurrentUser ¶
GetCurrentUser returns the logged in user.
func (*Handlers) GetProject ¶
GetProject.
func (*Handlers) GetProjectBoard ¶
GetProjectBoard.
func (*Handlers) GetProjectConfig ¶
GetProjectConfig.
func (*Handlers) GetProjectWorkitems ¶
func (h *Handlers) GetProjectWorkitems(c *gin.Context, project models.Project, params models.GetProjectWorkitemsParams)
GetProjectWorkitems.
func (*Handlers) InitializeProject ¶
InitializeProject.
func (*Handlers) MyProviderCallback ¶
func (*Handlers) MyProviderLogin ¶
func (*Handlers) OpenapiYamlGet ¶
OpenapiYamlGet returns this very openapi spec.
func (*Handlers) UpdateProjectConfig ¶
UpdateProjectConfig.
func (*Handlers) UpdateUser ¶
UpdateUser updates the user by id.
func (*Handlers) UpdateUserAuthorization ¶
UpdateUserAuthorization updates authorization information, e.g. roles, scopes.
type MiddlewareFunc ¶
type MultiErrorHandler ¶
type MultiErrorHandler func(openapi3.MultiError) error
MultiErrorHandler is called when oapi returns a MultiError type.
type OAValidatorOptions ¶
type OAValidatorOptions struct { ValidateResponse bool ErrorHandler ErrorHandler Options openapi3filter.Options ParamDecoder openapi3filter.ContentParameterDecoder UserData interface{} MultiErrorHandler MultiErrorHandler }
OAValidatorOptions customizes request validation.
type OperationID ¶
type OperationID string
const ( // Operation IDs for the 'admin' tag. AdminPing OperationID = "AdminPing" // Operation IDs for the 'default' tag. OpenapiYamlGet OperationID = "OpenapiYamlGet" Ping OperationID = "Ping" // Operation IDs for the 'events' tag. Events OperationID = "Events" // Operation IDs for the 'oidc' tag. MyProviderCallback OperationID = "MyProviderCallback" MyProviderLogin OperationID = "MyProviderLogin" // Operation IDs for the 'project' tag. CreateWorkitemTag OperationID = "CreateWorkitemTag" GetProject OperationID = "GetProject" GetProjectBoard OperationID = "GetProjectBoard" GetProjectConfig OperationID = "GetProjectConfig" GetProjectWorkitems OperationID = "GetProjectWorkitems" InitializeProject OperationID = "InitializeProject" UpdateProjectConfig OperationID = "UpdateProjectConfig" // Operation IDs for the 'user' tag. DeleteUser OperationID = "DeleteUser" GetCurrentUser OperationID = "GetCurrentUser" UpdateUser OperationID = "UpdateUser" UpdateUserAuthorization OperationID = "UpdateUserAuthorization" // Operation IDs for the 'workitem' tag. CreateWorkitem OperationID = "CreateWorkitem" CreateWorkitemComment OperationID = "CreateWorkitemComment" DeleteWorkitem OperationID = "DeleteWorkitem" GetWorkitem OperationID = "GetWorkitem" UpdateWorkitem OperationID = "UpdateWorkitem" )
type ProjectBoardCreateRequest ¶
type ProjectBoardCreateRequest struct { // services models not needed yet, projectId is trivial to include in every request... // if services use db CreateParams as is we can also have specific per-project logic // anyway Teams *[]db.TeamCreateParams `json:"teams"` Tags *[]db.WorkItemTagCreateParams `json:"tags"` }
type ProjectBoardResponse ¶
type ProjectBoardResponse struct {
ProjectName
}
ProjectBoardResponse represents an OpenAPI schema response for a ProjectBoard.
type ProjectName ¶
type PubSub ¶
type PubSub struct {
// contains filtered or unexported fields
}
func NewPubSub ¶
func NewPubSub() *PubSub
in reality most messages wont run endlessly in a goroutine, we will e.g. send a message to event.WorkItemMoved every time services.WorkItems.Move(...) is called we would have a map of channels opened per user id like WorkItemMovedUserChans map[string]chan string (in the future we'll have many of these like MemberAssignedUserChans to notify when added to workitem, etc.) and send a message to all members with workitem.members' userIDs. We need specific channels so that when a message is consumed we add a hardcoded "event" name ( see enum Topics) and frontend properly handles it.
type ServerInterface ¶
type ServerInterface interface { // Ping pongs // (GET /admin/ping) AdminPing(c *gin.Context) // (GET /auth/myprovider/callback) MyProviderCallback(c *gin.Context) // (GET /auth/myprovider/login) MyProviderLogin(c *gin.Context) // (GET /events) Events(c *gin.Context, params externalRef0.EventsParams) // Returns this very OpenAPI spec. // (GET /openapi.yaml) OpenapiYamlGet(c *gin.Context) // Ping pongs // (GET /ping) Ping(c *gin.Context) // returns board data for a project // (GET /project/{projectName}/) GetProject(c *gin.Context, projectName externalRef0.ProjectName) // returns board data for a project // (GET /project/{projectName}/board) GetProjectBoard(c *gin.Context, projectName externalRef0.ProjectName) // returns the project configuration // (GET /project/{projectName}/config) GetProjectConfig(c *gin.Context, projectName externalRef0.ProjectName) // updates the project configuration // (PUT /project/{projectName}/config) UpdateProjectConfig(c *gin.Context, projectName externalRef0.ProjectName) // creates initial data (teams, tags...) for a new project // (POST /project/{projectName}/initialize) InitializeProject(c *gin.Context, projectName externalRef0.ProjectName) // create workitem tag // (POST /project/{projectName}/tag/) CreateWorkitemTag(c *gin.Context, projectName externalRef0.ProjectName) // returns workitems for a project // (GET /project/{projectName}/workitems) GetProjectWorkitems(c *gin.Context, projectName externalRef0.ProjectName, params externalRef0.GetProjectWorkitemsParams) // returns the logged in user // (GET /user/me) GetCurrentUser(c *gin.Context) // deletes the user by id // (DELETE /user/{id}) DeleteUser(c *gin.Context, id uuid.UUID) // updates the user by id // (PATCH /user/{id}) UpdateUser(c *gin.Context, id uuid.UUID) // updates user role and scopes by id // (PATCH /user/{id}/authorization) UpdateUserAuthorization(c *gin.Context, id uuid.UUID) // create workitem // (POST /workitem/) CreateWorkitem(c *gin.Context) // delete workitem // (DELETE /workitem/{id}/) DeleteWorkitem(c *gin.Context, id externalRef0.Serial) // get workitem // (GET /workitem/{id}/) GetWorkitem(c *gin.Context, id externalRef0.Serial) // update workitem // (PATCH /workitem/{id}/) UpdateWorkitem(c *gin.Context, id externalRef0.Serial) // create workitem comment // (POST /workitem/{id}/comments/) CreateWorkitemComment(c *gin.Context, id externalRef0.Serial) // contains filtered or unexported methods }
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
ServerInterfaceWrapper converts contexts to parameters.
func (*ServerInterfaceWrapper) AdminPing ¶
func (siw *ServerInterfaceWrapper) AdminPing(c *gin.Context)
AdminPing operation with its own middleware.
func (*ServerInterfaceWrapper) CreateWorkitem ¶
func (siw *ServerInterfaceWrapper) CreateWorkitem(c *gin.Context)
CreateWorkitem operation with its own middleware.
func (*ServerInterfaceWrapper) CreateWorkitemComment ¶
func (siw *ServerInterfaceWrapper) CreateWorkitemComment(c *gin.Context)
CreateWorkitemComment operation with its own middleware.
func (*ServerInterfaceWrapper) CreateWorkitemTag ¶
func (siw *ServerInterfaceWrapper) CreateWorkitemTag(c *gin.Context)
CreateWorkitemTag operation with its own middleware.
func (*ServerInterfaceWrapper) DeleteUser ¶
func (siw *ServerInterfaceWrapper) DeleteUser(c *gin.Context)
DeleteUser operation with its own middleware.
func (*ServerInterfaceWrapper) DeleteWorkitem ¶
func (siw *ServerInterfaceWrapper) DeleteWorkitem(c *gin.Context)
DeleteWorkitem operation with its own middleware.
func (*ServerInterfaceWrapper) Events ¶
func (siw *ServerInterfaceWrapper) Events(c *gin.Context)
Events operation with its own middleware.
func (*ServerInterfaceWrapper) GetCurrentUser ¶
func (siw *ServerInterfaceWrapper) GetCurrentUser(c *gin.Context)
GetCurrentUser operation with its own middleware.
func (*ServerInterfaceWrapper) GetProject ¶
func (siw *ServerInterfaceWrapper) GetProject(c *gin.Context)
GetProject operation with its own middleware.
func (*ServerInterfaceWrapper) GetProjectBoard ¶
func (siw *ServerInterfaceWrapper) GetProjectBoard(c *gin.Context)
GetProjectBoard operation with its own middleware.
func (*ServerInterfaceWrapper) GetProjectConfig ¶
func (siw *ServerInterfaceWrapper) GetProjectConfig(c *gin.Context)
GetProjectConfig operation with its own middleware.
func (*ServerInterfaceWrapper) GetProjectWorkitems ¶
func (siw *ServerInterfaceWrapper) GetProjectWorkitems(c *gin.Context)
GetProjectWorkitems operation with its own middleware.
func (*ServerInterfaceWrapper) GetWorkitem ¶
func (siw *ServerInterfaceWrapper) GetWorkitem(c *gin.Context)
GetWorkitem operation with its own middleware.
func (*ServerInterfaceWrapper) InitializeProject ¶
func (siw *ServerInterfaceWrapper) InitializeProject(c *gin.Context)
InitializeProject operation with its own middleware.
func (*ServerInterfaceWrapper) MyProviderCallback ¶
func (siw *ServerInterfaceWrapper) MyProviderCallback(c *gin.Context)
MyProviderCallback operation with its own middleware.
func (*ServerInterfaceWrapper) MyProviderLogin ¶
func (siw *ServerInterfaceWrapper) MyProviderLogin(c *gin.Context)
MyProviderLogin operation with its own middleware.
func (*ServerInterfaceWrapper) OpenapiYamlGet ¶
func (siw *ServerInterfaceWrapper) OpenapiYamlGet(c *gin.Context)
OpenapiYamlGet operation with its own middleware.
func (*ServerInterfaceWrapper) Ping ¶
func (siw *ServerInterfaceWrapper) Ping(c *gin.Context)
Ping operation with its own middleware.
func (*ServerInterfaceWrapper) UpdateProjectConfig ¶
func (siw *ServerInterfaceWrapper) UpdateProjectConfig(c *gin.Context)
UpdateProjectConfig operation with its own middleware.
func (*ServerInterfaceWrapper) UpdateUser ¶
func (siw *ServerInterfaceWrapper) UpdateUser(c *gin.Context)
UpdateUser operation with its own middleware.
func (*ServerInterfaceWrapper) UpdateUserAuthorization ¶
func (siw *ServerInterfaceWrapper) UpdateUserAuthorization(c *gin.Context)
UpdateUserAuthorization operation with its own middleware.
func (*ServerInterfaceWrapper) UpdateWorkitem ¶
func (siw *ServerInterfaceWrapper) UpdateWorkitem(c *gin.Context)
UpdateWorkitem operation with its own middleware.
type ServerOption ¶
type ServerOption func(*Server)
func WithMiddlewares ¶
func WithMiddlewares(mws ...gin.HandlerFunc) ServerOption
WithMiddlewares adds the given middlewares before registering the main routers.
type SharedWorkItemFields ¶
type SharedWorkItemFields struct {}
type TeamCreateRequest ¶
type TeamCreateRequest struct {
db.TeamCreateParams
}
type TeamUpdateRequest ¶
type TeamUpdateRequest struct {
db.TeamUpdateParams
}
type User ¶
type User struct { db.User Role models.Role `json:"role" ref:"#/components/schemas/Role" required:"true"` APIKey *db.UserAPIKey `json:"apiKey,omitempty"` Teams *[]db.Team `json:"teams"` Projects *[]db.Project `json:"projects"` }
User represents an OpenAPI schema response for a User.
type UserNotificationsChan ¶
type UserNotificationsChan chan string
type WorkItemCommentCreateRequest ¶
type WorkItemCommentCreateRequest struct {
db.WorkItemCommentCreateParams
}
type WorkItemResponse ¶
WorkItemResponse represents an OpenAPI schema response for a WorkItem.
type WorkItemTagCreateRequest ¶
type WorkItemTagCreateRequest struct {
db.WorkItemTagCreateParams
}
Source Files ¶
- api.go
- api_admin.go
- api_auth_middlewares.gen.go
- api_default.go
- api_events.go
- api_oidc.go
- api_project.go
- api_user.go
- api_workitem.go
- context.go
- middleware.auth.go
- middleware.db.go
- middleware.openapi.go
- middleware.ratelimit.go
- models.go
- openapi.go
- openapi_server.gen.go
- operation_ids.gen.go
- otel.go
- responses.go
- server.go
- validate.go