代码拉取完成,页面将自动刷新
// Package ports provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen version (devel) DO NOT EDIT.
package main
import (
"context"
"fmt"
"gitee.com/jerryduren/architecture/go-with-domain/demo5gc/internal/smf/domain"
"github.com/go-chi/chi"
"net/http"
"github.com/deepmap/oapi-codegen/pkg/runtime"
)
// ServerInterface represents all server handlers.
type ServerInterface interface {
// Create SM Context
// (POST /sm-contexts)
PostSmContexts(w http.ResponseWriter, r *http.Request)
// Update SM Context
// (POST /sm-contexts/{smContextRef}/modify)
UpdateSmContext(w http.ResponseWriter, r *http.Request, smContextRef string)
// Release SM Context
// (POST /sm-contexts/{smContextRef}/release)
ReleaseSmContext(w http.ResponseWriter, r *http.Request, smContextRef string)
// Retrieve SM Context
// (POST /sm-contexts/{smContextRef}/retrieve)
RetrieveSmContext(w http.ResponseWriter, r *http.Request, smContextRef string)
}
// ServerInterfaceWrapper converts contexts to parameters.
type ServerInterfaceWrapper struct {
Handler ServerInterface
HandlerMiddlewares []MiddlewareFunc
}
type MiddlewareFunc func(http.HandlerFunc) http.HandlerFunc
// PostSmContexts operation middleware
func (siw *ServerInterfaceWrapper) PostSmContexts(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
ctx = context.WithValue(ctx, domain.OAuth2ClientCredentialsScopes, []string{"nsmf-pdusession"})
var handler = func(w http.ResponseWriter, r *http.Request) {
siw.Handler.PostSmContexts(w, r)
}
for _, middleware := range siw.HandlerMiddlewares {
handler = middleware(handler)
}
handler(w, r.WithContext(ctx))
}
// UpdateSmContext operation middleware
func (siw *ServerInterfaceWrapper) UpdateSmContext(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "smContextRef" -------------
var smContextRef string
err = runtime.BindStyledParameter("simple", false, "smContextRef", chi.URLParam(r, "smContextRef"), &smContextRef)
if err != nil {
http.Error(w, fmt.Sprintf("Invalid format for parameter smContextRef: %s", err), http.StatusBadRequest)
return
}
ctx = context.WithValue(ctx, domain.OAuth2ClientCredentialsScopes, []string{"nsmf-pdusession"})
var handler = func(w http.ResponseWriter, r *http.Request) {
siw.Handler.UpdateSmContext(w, r, smContextRef)
}
for _, middleware := range siw.HandlerMiddlewares {
handler = middleware(handler)
}
handler(w, r.WithContext(ctx))
}
// ReleaseSmContext operation middleware
func (siw *ServerInterfaceWrapper) ReleaseSmContext(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "smContextRef" -------------
var smContextRef string
err = runtime.BindStyledParameter("simple", false, "smContextRef", chi.URLParam(r, "smContextRef"), &smContextRef)
if err != nil {
http.Error(w, fmt.Sprintf("Invalid format for parameter smContextRef: %s", err), http.StatusBadRequest)
return
}
ctx = context.WithValue(ctx, domain.OAuth2ClientCredentialsScopes, []string{"nsmf-pdusession"})
var handler = func(w http.ResponseWriter, r *http.Request) {
siw.Handler.ReleaseSmContext(w, r, smContextRef)
}
for _, middleware := range siw.HandlerMiddlewares {
handler = middleware(handler)
}
handler(w, r.WithContext(ctx))
}
// RetrieveSmContext operation middleware
func (siw *ServerInterfaceWrapper) RetrieveSmContext(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "smContextRef" -------------
var smContextRef string
err = runtime.BindStyledParameter("simple", false, "smContextRef", chi.URLParam(r, "smContextRef"), &smContextRef)
if err != nil {
http.Error(w, fmt.Sprintf("Invalid format for parameter smContextRef: %s", err), http.StatusBadRequest)
return
}
ctx = context.WithValue(ctx, domain.OAuth2ClientCredentialsScopes, []string{"nsmf-pdusession"})
var handler = func(w http.ResponseWriter, r *http.Request) {
siw.Handler.RetrieveSmContext(w, r, smContextRef)
}
for _, middleware := range siw.HandlerMiddlewares {
handler = middleware(handler)
}
handler(w, r.WithContext(ctx))
}
// Handler creates http.Handler with routing matching OpenAPI spec.
func Handler(si ServerInterface) http.Handler {
return HandlerWithOptions(si, ChiServerOptions{})
}
type ChiServerOptions struct {
BaseURL string
BaseRouter chi.Router
Middlewares []MiddlewareFunc
}
// HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.
func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler {
return HandlerWithOptions(si, ChiServerOptions{
BaseRouter: r,
})
}
func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler {
return HandlerWithOptions(si, ChiServerOptions{
BaseURL: baseURL,
BaseRouter: r,
})
}
// HandlerWithOptions creates http.Handler with additional options
func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler {
r := options.BaseRouter
if r == nil {
r = chi.NewRouter()
}
wrapper := ServerInterfaceWrapper{
Handler: si,
HandlerMiddlewares: options.Middlewares,
}
r.Group(func(r chi.Router) {
r.Post(options.BaseURL+"/sm-contexts", wrapper.PostSmContexts)
})
r.Group(func(r chi.Router) {
r.Post(options.BaseURL+"/sm-contexts/{smContextRef}/modify", wrapper.UpdateSmContext)
})
r.Group(func(r chi.Router) {
r.Post(options.BaseURL+"/sm-contexts/{smContextRef}/release", wrapper.ReleaseSmContext)
})
r.Group(func(r chi.Router) {
r.Post(options.BaseURL+"/sm-contexts/{smContextRef}/retrieve", wrapper.RetrieveSmContext)
})
return r
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。