http_server

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package http_server provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen DO NOT EDIT.

Index

Constants

View Source
const (
	AccessTokenScopes = "AccessToken.Scopes"
	LoginScopes       = "Login.Scopes"
)

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (*openapi3.Swagger, error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file.

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

Types

type ChiServerOptions

type ChiServerOptions struct {
	BaseURL     string
	BaseRouter  chi.Router
	Middlewares []MiddlewareFunc
}

type ErrorInfo

type ErrorInfo struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

ErrorInfo defines model for ErrorInfo.

type GetUsersParams

type GetUsersParams struct {
	Offset *Offset `json:"Offset,omitempty"`
	Limit  *Limit  `json:"Limit,omitempty"`
}

GetUsersParams defines parameters for GetUsers.

type Limit

type Limit int

Limit defines model for Limit.

type ListMeta

type ListMeta struct {
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
	Total  int `json:"total"`
}

ListMeta defines model for ListMeta.

type MiddlewareFunc

type MiddlewareFunc func(http.HandlerFunc) http.HandlerFunc

type Offset

type Offset int

Offset defines model for Offset.

type PostTokensRefreshJSONBody

type PostTokensRefreshJSONBody TokenRefresh

PostTokensRefreshJSONBody defines parameters for PostTokensRefresh.

type PostTokensRefreshJSONRequestBody

type PostTokensRefreshJSONRequestBody PostTokensRefreshJSONBody

PostTokensRefreshJSONRequestBody defines body for PostTokensRefresh for application/json ContentType.

type PostUsersJSONBody

type PostUsersJSONBody UserCreate

PostUsersJSONBody defines parameters for PostUsers.

type PostUsersJSONRequestBody

type PostUsersJSONRequestBody PostUsersJSONBody

PostUsersJSONRequestBody defines body for PostUsers for application/json ContentType.

type PutUsersMeJSONBody

type PutUsersMeJSONBody UserUpdate

PutUsersMeJSONBody defines parameters for PutUsersMe.

type PutUsersMeJSONRequestBody

type PutUsersMeJSONRequestBody PutUsersMeJSONBody

PutUsersMeJSONRequestBody defines body for PutUsersMe for application/json ContentType.

type PutUsersUserIDJSONBody

type PutUsersUserIDJSONBody UserUpdate

PutUsersUserIDJSONBody defines parameters for PutUsersUserID.

type PutUsersUserIDJSONRequestBody

type PutUsersUserIDJSONRequestBody PutUsersUserIDJSONBody

PutUsersUserIDJSONRequestBody defines body for PutUsersUserID for application/json ContentType.

type ServerHTTP

type ServerHTTP struct {
	// contains filtered or unexported fields
}

ServerHTTP

func New

func New(d *domain.Domain, url string, e *casbin.Enforcer) (*ServerHTTP, error)

func (*ServerHTTP) DeleteUsersMe

func (s *ServerHTTP) DeleteUsersMe(w http.ResponseWriter, r *http.Request)

Delete me

func (*ServerHTTP) DeleteUsersUserID

func (s *ServerHTTP) DeleteUsersUserID(w http.ResponseWriter, r *http.Request, userID UserID)

Delete a user

func (*ServerHTTP) GetUsers

func (s *ServerHTTP) GetUsers(w http.ResponseWriter, r *http.Request, params GetUsersParams)

List users

func (*ServerHTTP) GetUsersMe

func (s *ServerHTTP) GetUsersMe(w http.ResponseWriter, r *http.Request)

Get me

func (*ServerHTTP) GetUsersUserID

func (s *ServerHTTP) GetUsersUserID(w http.ResponseWriter, r *http.Request, userID UserID)

Get a user

func (*ServerHTTP) ListenAndServe

func (s *ServerHTTP) ListenAndServe()

func (*ServerHTTP) PostTokensLogin

func (s *ServerHTTP) PostTokensLogin(w http.ResponseWriter, r *http.Request)

Login

func (*ServerHTTP) PostTokensRefresh

func (s *ServerHTTP) PostTokensRefresh(w http.ResponseWriter, r *http.Request)

func (*ServerHTTP) PostUsers

func (s *ServerHTTP) PostUsers(w http.ResponseWriter, r *http.Request)

Create a user

func (*ServerHTTP) PutUsersMe

func (s *ServerHTTP) PutUsersMe(w http.ResponseWriter, r *http.Request)

Update me

func (*ServerHTTP) PutUsersUserID

func (s *ServerHTTP) PutUsersUserID(w http.ResponseWriter, r *http.Request, userID UserID)

Update a user

func (*ServerHTTP) Shutdown

func (s *ServerHTTP) Shutdown()

type ServerInterface

type ServerInterface interface {

	// (POST /tokens/login)
	PostTokensLogin(w http.ResponseWriter, r *http.Request)

	// (POST /tokens/refresh)
	PostTokensRefresh(w http.ResponseWriter, r *http.Request)

	// (GET /users)
	GetUsers(w http.ResponseWriter, r *http.Request, params GetUsersParams)

	// (POST /users)
	PostUsers(w http.ResponseWriter, r *http.Request)

	// (DELETE /users/me)
	DeleteUsersMe(w http.ResponseWriter, r *http.Request)

	// (GET /users/me)
	GetUsersMe(w http.ResponseWriter, r *http.Request)

	// (PUT /users/me)
	PutUsersMe(w http.ResponseWriter, r *http.Request)

	// (DELETE /users/{UserID})
	DeleteUsersUserID(w http.ResponseWriter, r *http.Request, userID UserID)

	// (GET /users/{UserID})
	GetUsersUserID(w http.ResponseWriter, r *http.Request, userID UserID)

	// (PUT /users/{UserID})
	PutUsersUserID(w http.ResponseWriter, r *http.Request, userID UserID)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) DeleteUsersMe

func (siw *ServerInterfaceWrapper) DeleteUsersMe(w http.ResponseWriter, r *http.Request)

DeleteUsersMe operation middleware

func (*ServerInterfaceWrapper) DeleteUsersUserID

func (siw *ServerInterfaceWrapper) DeleteUsersUserID(w http.ResponseWriter, r *http.Request)

DeleteUsersUserID operation middleware

func (*ServerInterfaceWrapper) GetUsers

func (siw *ServerInterfaceWrapper) GetUsers(w http.ResponseWriter, r *http.Request)

GetUsers operation middleware

func (*ServerInterfaceWrapper) GetUsersMe

func (siw *ServerInterfaceWrapper) GetUsersMe(w http.ResponseWriter, r *http.Request)

GetUsersMe operation middleware

func (*ServerInterfaceWrapper) GetUsersUserID

func (siw *ServerInterfaceWrapper) GetUsersUserID(w http.ResponseWriter, r *http.Request)

GetUsersUserID operation middleware

func (*ServerInterfaceWrapper) PostTokensLogin

func (siw *ServerInterfaceWrapper) PostTokensLogin(w http.ResponseWriter, r *http.Request)

PostTokensLogin operation middleware

func (*ServerInterfaceWrapper) PostTokensRefresh

func (siw *ServerInterfaceWrapper) PostTokensRefresh(w http.ResponseWriter, r *http.Request)

PostTokensRefresh operation middleware

func (*ServerInterfaceWrapper) PostUsers

func (siw *ServerInterfaceWrapper) PostUsers(w http.ResponseWriter, r *http.Request)

PostUsers operation middleware

func (*ServerInterfaceWrapper) PutUsersMe

func (siw *ServerInterfaceWrapper) PutUsersMe(w http.ResponseWriter, r *http.Request)

PutUsersMe operation middleware

func (*ServerInterfaceWrapper) PutUsersUserID

func (siw *ServerInterfaceWrapper) PutUsersUserID(w http.ResponseWriter, r *http.Request)

PutUsersUserID operation middleware

type TokenInfo

type TokenInfo struct {
	ExpiresAt time.Time `json:"expiresAt"`
	IssuedAt  time.Time `json:"issuedAt"`
	Token     string    `json:"token"`
}

TokenInfo defines model for TokenInfo.

type TokenInfos

type TokenInfos struct {
	AccessToken  TokenInfo `json:"accessToken"`
	RefreshToken TokenInfo `json:"refreshToken"`
}

TokenInfos defines model for TokenInfos.

type TokenRefresh

type TokenRefresh struct {
	RefreshToken string `json:"refreshToken"`
}

TokenRefresh defines model for TokenRefresh.

func (*TokenRefresh) Bind

func (u *TokenRefresh) Bind(r *http.Request) error

type UserCreate

type UserCreate struct {
	Email    string   `json:"email"`
	LoginId  string   `json:"loginId"`
	Password string   `json:"password"`
	Phone    string   `json:"phone"`
	Role     UserRole `json:"role"`
}

UserCreate defines model for UserCreate.

func (*UserCreate) Bind

func (u *UserCreate) Bind(r *http.Request) error

type UserID

type UserID string

UserID defines model for UserID.

func (*UserID) Validate

func (u *UserID) Validate() error

Validate & Bind

type UserInfo

type UserInfo struct {
	Email   string   `json:"email"`
	Id      string   `json:"id"`
	LoginId string   `json:"loginId"`
	Phone   string   `json:"phone"`
	Role    UserRole `json:"role"`
}

UserInfo defines model for UserInfo.

func UserModelListToUserInfoList

func UserModelListToUserInfoList(userModelList []entity.UserInfo) []UserInfo

func UserModelToUserInfo

func UserModelToUserInfo(userModel *entity.UserInfo) *UserInfo

type UserInfoList

type UserInfoList struct {
	Metadata ListMeta   `json:"metadata"`
	Users    []UserInfo `json:"users"`
}

UserInfoList defines model for UserInfoList.

type UserRole

type UserRole string

UserRole defines model for UserRole.

const (
	UserRole_admin UserRole = "admin"
	UserRole_user  UserRole = "user"
)

List of UserRole

type UserUpdate

type UserUpdate struct {
	Email    string   `json:"email"`
	Password string   `json:"password"`
	Phone    string   `json:"phone"`
	Role     UserRole `json:"role"`
}

UserUpdate defines model for UserUpdate.

func (*UserUpdate) Bind

func (u *UserUpdate) Bind(r *http.Request) error

Jump to

Keyboard shortcuts

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