1
0
api/ent/ogent/oas_handlers_gen.go
2024-02-04 17:53:47 +09:00

2873 lines
65 KiB
Go

// Code generated by ogen, DO NOT EDIT.
package ogent
import (
"context"
"net/http"
"time"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
"go.opentelemetry.io/otel/trace"
"github.com/ogen-go/ogen/middleware"
"github.com/ogen-go/ogen/ogenerrors"
"github.com/ogen-go/ogen/otelogen"
)
// handleCreateCardRequest handles createCard operation.
//
// Creates a new Card and persists it to storage.
//
// POST /cards
func (s *Server) handleCreateCardRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("createCard"),
semconv.HTTPMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/cards"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "CreateCard",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "CreateCard",
ID: "createCard",
}
)
request, close, err := s.decodeCreateCardRequest(r)
if err != nil {
err = &ogenerrors.DecodeRequestError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeRequest", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
defer func() {
if err := close(); err != nil {
recordError("CloseRequest", err)
}
}()
var response CreateCardRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "CreateCard",
OperationID: "createCard",
Body: request,
Params: middleware.Parameters{},
Raw: r,
}
type (
Request = *CreateCardReq
Params = struct{}
Response = CreateCardRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
nil,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.CreateCard(ctx, request)
return response, err
},
)
} else {
response, err = s.h.CreateCard(ctx, request)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeCreateCardResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleCreateGroupRequest handles createGroup operation.
//
// Creates a new Group and persists it to storage.
//
// POST /groups
func (s *Server) handleCreateGroupRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("createGroup"),
semconv.HTTPMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/groups"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "CreateGroup",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "CreateGroup",
ID: "createGroup",
}
)
request, close, err := s.decodeCreateGroupRequest(r)
if err != nil {
err = &ogenerrors.DecodeRequestError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeRequest", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
defer func() {
if err := close(); err != nil {
recordError("CloseRequest", err)
}
}()
var response CreateGroupRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "CreateGroup",
OperationID: "createGroup",
Body: request,
Params: middleware.Parameters{},
Raw: r,
}
type (
Request = *CreateGroupReq
Params = struct{}
Response = CreateGroupRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
nil,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.CreateGroup(ctx, request)
return response, err
},
)
} else {
response, err = s.h.CreateGroup(ctx, request)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeCreateGroupResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleCreateUeRequest handles createUe operation.
//
// Creates a new Ue and persists it to storage.
//
// POST /ues
func (s *Server) handleCreateUeRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("createUe"),
semconv.HTTPMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/ues"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "CreateUe",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "CreateUe",
ID: "createUe",
}
)
request, close, err := s.decodeCreateUeRequest(r)
if err != nil {
err = &ogenerrors.DecodeRequestError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeRequest", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
defer func() {
if err := close(); err != nil {
recordError("CloseRequest", err)
}
}()
var response CreateUeRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "CreateUe",
OperationID: "createUe",
Body: request,
Params: middleware.Parameters{},
Raw: r,
}
type (
Request = *CreateUeReq
Params = struct{}
Response = CreateUeRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
nil,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.CreateUe(ctx, request)
return response, err
},
)
} else {
response, err = s.h.CreateUe(ctx, request)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeCreateUeResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleCreateUserRequest handles createUser operation.
//
// Creates a new User and persists it to storage.
//
// POST /users
func (s *Server) handleCreateUserRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("createUser"),
semconv.HTTPMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/users"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "CreateUser",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "CreateUser",
ID: "createUser",
}
)
request, close, err := s.decodeCreateUserRequest(r)
if err != nil {
err = &ogenerrors.DecodeRequestError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeRequest", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
defer func() {
if err := close(); err != nil {
recordError("CloseRequest", err)
}
}()
var response CreateUserRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "CreateUser",
OperationID: "createUser",
Body: request,
Params: middleware.Parameters{},
Raw: r,
}
type (
Request = *CreateUserReq
Params = struct{}
Response = CreateUserRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
nil,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.CreateUser(ctx, request)
return response, err
},
)
} else {
response, err = s.h.CreateUser(ctx, request)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeCreateUserResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleDeleteCardRequest handles deleteCard operation.
//
// Deletes the Card with the requested ID.
//
// DELETE /cards/{id}
func (s *Server) handleDeleteCardRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("deleteCard"),
semconv.HTTPMethodKey.String("DELETE"),
semconv.HTTPRouteKey.String("/cards/{id}"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "DeleteCard",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "DeleteCard",
ID: "deleteCard",
}
)
params, err := decodeDeleteCardParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response DeleteCardRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "DeleteCard",
OperationID: "deleteCard",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = struct{}
Params = DeleteCardParams
Response = DeleteCardRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackDeleteCardParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.DeleteCard(ctx, params)
return response, err
},
)
} else {
response, err = s.h.DeleteCard(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeDeleteCardResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleDeleteGroupRequest handles deleteGroup operation.
//
// Deletes the Group with the requested ID.
//
// DELETE /groups/{id}
func (s *Server) handleDeleteGroupRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("deleteGroup"),
semconv.HTTPMethodKey.String("DELETE"),
semconv.HTTPRouteKey.String("/groups/{id}"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "DeleteGroup",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "DeleteGroup",
ID: "deleteGroup",
}
)
params, err := decodeDeleteGroupParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response DeleteGroupRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "DeleteGroup",
OperationID: "deleteGroup",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = struct{}
Params = DeleteGroupParams
Response = DeleteGroupRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackDeleteGroupParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.DeleteGroup(ctx, params)
return response, err
},
)
} else {
response, err = s.h.DeleteGroup(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeDeleteGroupResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleDeleteUeRequest handles deleteUe operation.
//
// Deletes the Ue with the requested ID.
//
// DELETE /ues/{id}
func (s *Server) handleDeleteUeRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("deleteUe"),
semconv.HTTPMethodKey.String("DELETE"),
semconv.HTTPRouteKey.String("/ues/{id}"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "DeleteUe",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "DeleteUe",
ID: "deleteUe",
}
)
params, err := decodeDeleteUeParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response DeleteUeRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "DeleteUe",
OperationID: "deleteUe",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = struct{}
Params = DeleteUeParams
Response = DeleteUeRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackDeleteUeParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.DeleteUe(ctx, params)
return response, err
},
)
} else {
response, err = s.h.DeleteUe(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeDeleteUeResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleDeleteUserRequest handles deleteUser operation.
//
// Deletes the User with the requested ID.
//
// DELETE /users/{id}
func (s *Server) handleDeleteUserRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("deleteUser"),
semconv.HTTPMethodKey.String("DELETE"),
semconv.HTTPRouteKey.String("/users/{id}"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "DeleteUser",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "DeleteUser",
ID: "deleteUser",
}
)
params, err := decodeDeleteUserParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response DeleteUserRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "DeleteUser",
OperationID: "deleteUser",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = struct{}
Params = DeleteUserParams
Response = DeleteUserRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackDeleteUserParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.DeleteUser(ctx, params)
return response, err
},
)
} else {
response, err = s.h.DeleteUser(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeDeleteUserResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleDrawDoneRequest handles drawDone operation.
//
// Draws a card item as done.
//
// PUT /cards/{id}/d
func (s *Server) handleDrawDoneRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("drawDone"),
semconv.HTTPMethodKey.String("PUT"),
semconv.HTTPRouteKey.String("/cards/{id}/d"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "DrawDone",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "DrawDone",
ID: "drawDone",
}
)
params, err := decodeDrawDoneParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response *DrawDoneNoContent
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "DrawDone",
OperationID: "drawDone",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = struct{}
Params = DrawDoneParams
Response = *DrawDoneNoContent
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackDrawDoneParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
err = s.h.DrawDone(ctx, params)
return response, err
},
)
} else {
err = s.h.DrawDone(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeDrawDoneResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleDrawStartRequest handles drawStart operation.
//
// Draws a card item as done.
//
// PATCH /users/{id}/card/start
func (s *Server) handleDrawStartRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("drawStart"),
semconv.HTTPMethodKey.String("PATCH"),
semconv.HTTPRouteKey.String("/users/{id}/card/start"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "DrawStart",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "DrawStart",
ID: "drawStart",
}
)
params, err := decodeDrawStartParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response *DrawStartNoContent
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "DrawStart",
OperationID: "drawStart",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = struct{}
Params = DrawStartParams
Response = *DrawStartNoContent
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackDrawStartParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
err = s.h.DrawStart(ctx, params)
return response, err
},
)
} else {
err = s.h.DrawStart(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeDrawStartResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleListCardRequest handles listCard operation.
//
// List Cards.
//
// GET /cards
func (s *Server) handleListCardRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("listCard"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/cards"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ListCard",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ListCard",
ID: "listCard",
}
)
params, err := decodeListCardParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ListCardRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ListCard",
OperationID: "listCard",
Body: nil,
Params: middleware.Parameters{
{
Name: "page",
In: "query",
}: params.Page,
{
Name: "itemsPerPage",
In: "query",
}: params.ItemsPerPage,
},
Raw: r,
}
type (
Request = struct{}
Params = ListCardParams
Response = ListCardRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackListCardParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ListCard(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ListCard(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeListCardResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleListGroupRequest handles listGroup operation.
//
// List Groups.
//
// GET /groups
func (s *Server) handleListGroupRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("listGroup"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/groups"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ListGroup",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ListGroup",
ID: "listGroup",
}
)
params, err := decodeListGroupParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ListGroupRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ListGroup",
OperationID: "listGroup",
Body: nil,
Params: middleware.Parameters{
{
Name: "page",
In: "query",
}: params.Page,
{
Name: "itemsPerPage",
In: "query",
}: params.ItemsPerPage,
},
Raw: r,
}
type (
Request = struct{}
Params = ListGroupParams
Response = ListGroupRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackListGroupParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ListGroup(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ListGroup(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeListGroupResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleListGroupUsersRequest handles listGroupUsers operation.
//
// List attached Users.
//
// GET /groups/{id}/users
func (s *Server) handleListGroupUsersRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("listGroupUsers"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/groups/{id}/users"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ListGroupUsers",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ListGroupUsers",
ID: "listGroupUsers",
}
)
params, err := decodeListGroupUsersParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ListGroupUsersRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ListGroupUsers",
OperationID: "listGroupUsers",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
{
Name: "page",
In: "query",
}: params.Page,
{
Name: "itemsPerPage",
In: "query",
}: params.ItemsPerPage,
},
Raw: r,
}
type (
Request = struct{}
Params = ListGroupUsersParams
Response = ListGroupUsersRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackListGroupUsersParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ListGroupUsers(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ListGroupUsers(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeListGroupUsersResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleListUeRequest handles listUe operation.
//
// List Ues.
//
// GET /ues
func (s *Server) handleListUeRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("listUe"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/ues"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ListUe",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ListUe",
ID: "listUe",
}
)
params, err := decodeListUeParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ListUeRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ListUe",
OperationID: "listUe",
Body: nil,
Params: middleware.Parameters{
{
Name: "page",
In: "query",
}: params.Page,
{
Name: "itemsPerPage",
In: "query",
}: params.ItemsPerPage,
},
Raw: r,
}
type (
Request = struct{}
Params = ListUeParams
Response = ListUeRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackListUeParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ListUe(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ListUe(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeListUeResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleListUserRequest handles listUser operation.
//
// List Users.
//
// GET /users
func (s *Server) handleListUserRequest(args [0]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("listUser"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/users"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ListUser",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ListUser",
ID: "listUser",
}
)
params, err := decodeListUserParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ListUserRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ListUser",
OperationID: "listUser",
Body: nil,
Params: middleware.Parameters{
{
Name: "page",
In: "query",
}: params.Page,
{
Name: "itemsPerPage",
In: "query",
}: params.ItemsPerPage,
},
Raw: r,
}
type (
Request = struct{}
Params = ListUserParams
Response = ListUserRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackListUserParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ListUser(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ListUser(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeListUserResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleListUserCardRequest handles listUserCard operation.
//
// List attached Cards.
//
// GET /users/{id}/card
func (s *Server) handleListUserCardRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("listUserCard"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/users/{id}/card"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ListUserCard",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ListUserCard",
ID: "listUserCard",
}
)
params, err := decodeListUserCardParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ListUserCardRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ListUserCard",
OperationID: "listUserCard",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
{
Name: "page",
In: "query",
}: params.Page,
{
Name: "itemsPerPage",
In: "query",
}: params.ItemsPerPage,
},
Raw: r,
}
type (
Request = struct{}
Params = ListUserCardParams
Response = ListUserCardRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackListUserCardParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ListUserCard(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ListUserCard(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeListUserCardResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleListUserUeRequest handles listUserUe operation.
//
// List attached Ues.
//
// GET /users/{id}/ue
func (s *Server) handleListUserUeRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("listUserUe"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/users/{id}/ue"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ListUserUe",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ListUserUe",
ID: "listUserUe",
}
)
params, err := decodeListUserUeParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ListUserUeRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ListUserUe",
OperationID: "listUserUe",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
{
Name: "page",
In: "query",
}: params.Page,
{
Name: "itemsPerPage",
In: "query",
}: params.ItemsPerPage,
},
Raw: r,
}
type (
Request = struct{}
Params = ListUserUeParams
Response = ListUserUeRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackListUserUeParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ListUserUe(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ListUserUe(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeListUserUeResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleReadCardRequest handles readCard operation.
//
// Finds the Card with the requested ID and returns it.
//
// GET /cards/{id}
func (s *Server) handleReadCardRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("readCard"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/cards/{id}"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ReadCard",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ReadCard",
ID: "readCard",
}
)
params, err := decodeReadCardParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ReadCardRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ReadCard",
OperationID: "readCard",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = struct{}
Params = ReadCardParams
Response = ReadCardRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackReadCardParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ReadCard(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ReadCard(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeReadCardResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleReadCardOwnerRequest handles readCardOwner operation.
//
// Find the attached User of the Card with the given ID.
//
// GET /cards/{id}/owner
func (s *Server) handleReadCardOwnerRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("readCardOwner"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/cards/{id}/owner"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ReadCardOwner",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ReadCardOwner",
ID: "readCardOwner",
}
)
params, err := decodeReadCardOwnerParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ReadCardOwnerRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ReadCardOwner",
OperationID: "readCardOwner",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = struct{}
Params = ReadCardOwnerParams
Response = ReadCardOwnerRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackReadCardOwnerParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ReadCardOwner(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ReadCardOwner(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeReadCardOwnerResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleReadGroupRequest handles readGroup operation.
//
// Finds the Group with the requested ID and returns it.
//
// GET /groups/{id}
func (s *Server) handleReadGroupRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("readGroup"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/groups/{id}"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ReadGroup",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ReadGroup",
ID: "readGroup",
}
)
params, err := decodeReadGroupParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ReadGroupRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ReadGroup",
OperationID: "readGroup",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = struct{}
Params = ReadGroupParams
Response = ReadGroupRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackReadGroupParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ReadGroup(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ReadGroup(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeReadGroupResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleReadUeRequest handles readUe operation.
//
// Finds the Ue with the requested ID and returns it.
//
// GET /ues/{id}
func (s *Server) handleReadUeRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("readUe"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/ues/{id}"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ReadUe",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ReadUe",
ID: "readUe",
}
)
params, err := decodeReadUeParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ReadUeRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ReadUe",
OperationID: "readUe",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = struct{}
Params = ReadUeParams
Response = ReadUeRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackReadUeParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ReadUe(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ReadUe(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeReadUeResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleReadUeOwnerRequest handles readUeOwner operation.
//
// Find the attached User of the Ue with the given ID.
//
// GET /ues/{id}/owner
func (s *Server) handleReadUeOwnerRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("readUeOwner"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/ues/{id}/owner"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ReadUeOwner",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ReadUeOwner",
ID: "readUeOwner",
}
)
params, err := decodeReadUeOwnerParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ReadUeOwnerRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ReadUeOwner",
OperationID: "readUeOwner",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = struct{}
Params = ReadUeOwnerParams
Response = ReadUeOwnerRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackReadUeOwnerParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ReadUeOwner(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ReadUeOwner(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeReadUeOwnerResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleReadUserRequest handles readUser operation.
//
// Finds the User with the requested ID and returns it.
//
// GET /users/{id}
func (s *Server) handleReadUserRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("readUser"),
semconv.HTTPMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/users/{id}"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "ReadUser",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "ReadUser",
ID: "readUser",
}
)
params, err := decodeReadUserParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var response ReadUserRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "ReadUser",
OperationID: "readUser",
Body: nil,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = struct{}
Params = ReadUserParams
Response = ReadUserRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackReadUserParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ReadUser(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ReadUser(ctx, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeReadUserResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleUpdateCardRequest handles updateCard operation.
//
// Updates a Card and persists changes to storage.
//
// PATCH /cards/{id}
func (s *Server) handleUpdateCardRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("updateCard"),
semconv.HTTPMethodKey.String("PATCH"),
semconv.HTTPRouteKey.String("/cards/{id}"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "UpdateCard",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "UpdateCard",
ID: "updateCard",
}
)
params, err := decodeUpdateCardParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
request, close, err := s.decodeUpdateCardRequest(r)
if err != nil {
err = &ogenerrors.DecodeRequestError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeRequest", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
defer func() {
if err := close(); err != nil {
recordError("CloseRequest", err)
}
}()
var response UpdateCardRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "UpdateCard",
OperationID: "updateCard",
Body: request,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = *UpdateCardReq
Params = UpdateCardParams
Response = UpdateCardRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackUpdateCardParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.UpdateCard(ctx, request, params)
return response, err
},
)
} else {
response, err = s.h.UpdateCard(ctx, request, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeUpdateCardResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleUpdateGroupRequest handles updateGroup operation.
//
// Updates a Group and persists changes to storage.
//
// PATCH /groups/{id}
func (s *Server) handleUpdateGroupRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("updateGroup"),
semconv.HTTPMethodKey.String("PATCH"),
semconv.HTTPRouteKey.String("/groups/{id}"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "UpdateGroup",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "UpdateGroup",
ID: "updateGroup",
}
)
params, err := decodeUpdateGroupParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
request, close, err := s.decodeUpdateGroupRequest(r)
if err != nil {
err = &ogenerrors.DecodeRequestError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeRequest", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
defer func() {
if err := close(); err != nil {
recordError("CloseRequest", err)
}
}()
var response UpdateGroupRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "UpdateGroup",
OperationID: "updateGroup",
Body: request,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = *UpdateGroupReq
Params = UpdateGroupParams
Response = UpdateGroupRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackUpdateGroupParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.UpdateGroup(ctx, request, params)
return response, err
},
)
} else {
response, err = s.h.UpdateGroup(ctx, request, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeUpdateGroupResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleUpdateUeRequest handles updateUe operation.
//
// Updates a Ue and persists changes to storage.
//
// PATCH /ues/{id}
func (s *Server) handleUpdateUeRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("updateUe"),
semconv.HTTPMethodKey.String("PATCH"),
semconv.HTTPRouteKey.String("/ues/{id}"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "UpdateUe",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "UpdateUe",
ID: "updateUe",
}
)
params, err := decodeUpdateUeParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
request, close, err := s.decodeUpdateUeRequest(r)
if err != nil {
err = &ogenerrors.DecodeRequestError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeRequest", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
defer func() {
if err := close(); err != nil {
recordError("CloseRequest", err)
}
}()
var response UpdateUeRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "UpdateUe",
OperationID: "updateUe",
Body: request,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = *UpdateUeReq
Params = UpdateUeParams
Response = UpdateUeRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackUpdateUeParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.UpdateUe(ctx, request, params)
return response, err
},
)
} else {
response, err = s.h.UpdateUe(ctx, request, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeUpdateUeResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}
// handleUpdateUserRequest handles updateUser operation.
//
// Updates a User and persists changes to storage.
//
// PATCH /users/{id}
func (s *Server) handleUpdateUserRequest(args [1]string, w http.ResponseWriter, r *http.Request) {
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("updateUser"),
semconv.HTTPMethodKey.String("PATCH"),
semconv.HTTPRouteKey.String("/users/{id}"),
}
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), "UpdateUser",
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
s.duration.Record(ctx, elapsedDuration.Microseconds(), otelAttrs...)
}()
// Increment request counter.
s.requests.Add(ctx, 1, otelAttrs...)
var (
recordError = func(stage string, err error) {
span.RecordError(err)
span.SetStatus(codes.Error, stage)
s.errors.Add(ctx, 1, otelAttrs...)
}
err error
opErrContext = ogenerrors.OperationContext{
Name: "UpdateUser",
ID: "updateUser",
}
)
params, err := decodeUpdateUserParams(args, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
request, close, err := s.decodeUpdateUserRequest(r)
if err != nil {
err = &ogenerrors.DecodeRequestError{
OperationContext: opErrContext,
Err: err,
}
recordError("DecodeRequest", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
defer func() {
if err := close(); err != nil {
recordError("CloseRequest", err)
}
}()
var response UpdateUserRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: "UpdateUser",
OperationID: "updateUser",
Body: request,
Params: middleware.Parameters{
{
Name: "id",
In: "path",
}: params.ID,
},
Raw: r,
}
type (
Request = *UpdateUserReq
Params = UpdateUserParams
Response = UpdateUserRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackUpdateUserParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.UpdateUser(ctx, request, params)
return response, err
},
)
} else {
response, err = s.h.UpdateUser(ctx, request, params)
}
if err != nil {
recordError("Internal", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeUpdateUserResponse(response, w, span); err != nil {
recordError("EncodeResponse", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
}