mirror of
https://github.com/openziti/zrok.git
synced 2024-12-22 14:50:55 +01:00
api package naming cleanup (less conflicts with existing ziti infrastructure)
This commit is contained in:
parent
0b6469b742
commit
84ac03c048
@ -15,7 +15,7 @@ zrokDir=$(realpath "$scriptDir/..")
|
||||
zrokSpec=$(realpath "$zrokDir/specs/zrok.yml")
|
||||
|
||||
echo "...generating zrok server"
|
||||
swagger generate server -f "$zrokSpec" -s rest_zrok_server -t "$zrokDir" -m "rest_model" --exclude-main
|
||||
swagger generate server -f "$zrokSpec" -s rest_server_zrok -t "$zrokDir" -m "rest_model_zrok" --exclude-main
|
||||
|
||||
echo "...generating zrok client"
|
||||
swagger generate client -f "$zrokSpec" -c rest_zrok_client -t "$zrokDir" -m "rest_model"
|
||||
swagger generate client -f "$zrokSpec" -c rest_client_zrok -t "$zrokDir" -m "rest_model_zrok"
|
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_client/metadata"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/metadata"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -4,12 +4,12 @@ import (
|
||||
"github.com/go-openapi/runtime"
|
||||
httptransport "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_client"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok"
|
||||
)
|
||||
|
||||
func newZrokClient() *rest_zrok_client.Zrok {
|
||||
func newZrokClient() *rest_client_zrok.Zrok {
|
||||
transport := httptransport.New(endpoint, "", nil)
|
||||
transport.Producers["application/zrok.v1+json"] = runtime.JSONProducer()
|
||||
transport.Consumers["application/zrok.v1+json"] = runtime.JSONConsumer()
|
||||
return rest_zrok_client.New(transport, strfmt.Default)
|
||||
return rest_client_zrok.New(transport, strfmt.Default)
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_client/identity"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/identity"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti/foundation/v2/term"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
@ -40,7 +40,7 @@ var createAccountCmd = &cobra.Command{
|
||||
|
||||
zrok := newZrokClient()
|
||||
req := identity.NewCreateAccountParams()
|
||||
req.Body = &rest_model.AccountRequest{
|
||||
req.Body = &rest_model_zrok.AccountRequest{
|
||||
Username: username,
|
||||
Password: password,
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_client/identity"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/identity"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
@ -27,7 +27,7 @@ func enable(_ *cobra.Command, args []string) {
|
||||
|
||||
zrok := newZrokClient()
|
||||
req := identity.NewEnableParams()
|
||||
req.Body = &rest_model.EnableRequest{
|
||||
req.Body = &rest_model_zrok.EnableRequest{
|
||||
Token: args[0],
|
||||
}
|
||||
resp, err := zrok.Identity.Enable(req)
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
"encoding/hex"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti-test-kitchen/zrok/controller/store"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations/identity"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/identity"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -44,7 +44,7 @@ func createAccountHandler(params identity.CreateAccountParams) middleware.Respon
|
||||
}
|
||||
|
||||
logrus.Infof("account created with id = '%v'", id)
|
||||
return identity.NewCreateAccountCreated().WithPayload(&rest_model.AccountResponse{
|
||||
return identity.NewCreateAccountCreated().WithPayload(&rest_model_zrok.AccountResponse{
|
||||
Token: token,
|
||||
})
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ import (
|
||||
"github.com/go-openapi/loads"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti-test-kitchen/zrok/controller/store"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_server"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations/identity"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations/metadata"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/identity"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/metadata"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@ -21,7 +21,7 @@ func Run(cfg *Config) error {
|
||||
return errors.Wrap(err, "error opening store")
|
||||
}
|
||||
|
||||
swaggerSpec, err := loads.Embedded(rest_zrok_server.SwaggerJSON, rest_zrok_server.FlatSwaggerJSON)
|
||||
swaggerSpec, err := loads.Embedded(rest_server_zrok.SwaggerJSON, rest_server_zrok.FlatSwaggerJSON)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error loading embedded swagger spec")
|
||||
}
|
||||
@ -31,7 +31,7 @@ func Run(cfg *Config) error {
|
||||
api.IdentityCreateAccountHandler = identity.CreateAccountHandlerFunc(createAccountHandler)
|
||||
api.IdentityEnableHandler = identity.EnableHandlerFunc(enableHandler)
|
||||
|
||||
server := rest_zrok_server.NewServer(api)
|
||||
server := rest_server_zrok.NewServer(api)
|
||||
defer func() { _ = server.Shutdown() }()
|
||||
server.Host = cfg.Host
|
||||
server.Port = cfg.Port
|
||||
@ -43,5 +43,5 @@ func Run(cfg *Config) error {
|
||||
}
|
||||
|
||||
func versionHandler(_ metadata.VersionParams) middleware.Responder {
|
||||
return metadata.NewGetOK().WithPayload(&rest_model.Version{Version: "v0.0.0; sk3tch"})
|
||||
return metadata.NewVersionOK().WithPayload(&rest_model_zrok.Version{Version: "v0.0.1; sk3tch"})
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
"fmt"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti-test-kitchen/zrok/controller/store"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations/identity"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/identity"
|
||||
"github.com/openziti/edge/rest_management_api_client"
|
||||
identity_edge "github.com/openziti/edge/rest_management_api_client/identity"
|
||||
rest_model_edge "github.com/openziti/edge/rest_model"
|
||||
@ -61,7 +61,7 @@ func enableHandler(params identity.EnableParams) middleware.Responder {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
resp := identity.NewEnableCreated().WithPayload(&rest_model.EnableResponse{
|
||||
resp := identity.NewEnableCreated().WithPayload(&rest_model_zrok.EnableResponse{
|
||||
Identity: ident.Payload.Data.ID,
|
||||
})
|
||||
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// NewCreateAccountParams creates a new CreateAccountParams object,
|
||||
@ -62,7 +62,7 @@ func NewCreateAccountParamsWithHTTPClient(client *http.Client) *CreateAccountPar
|
||||
type CreateAccountParams struct {
|
||||
|
||||
// Body.
|
||||
Body *rest_model.AccountRequest
|
||||
Body *rest_model_zrok.AccountRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
@ -118,13 +118,13 @@ func (o *CreateAccountParams) SetHTTPClient(client *http.Client) {
|
||||
}
|
||||
|
||||
// WithBody adds the body to the create account params
|
||||
func (o *CreateAccountParams) WithBody(body *rest_model.AccountRequest) *CreateAccountParams {
|
||||
func (o *CreateAccountParams) WithBody(body *rest_model_zrok.AccountRequest) *CreateAccountParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the create account params
|
||||
func (o *CreateAccountParams) SetBody(body *rest_model.AccountRequest) {
|
||||
func (o *CreateAccountParams) SetBody(body *rest_model_zrok.AccountRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// CreateAccountReader is a Reader for the CreateAccount structure.
|
||||
@ -56,19 +56,19 @@ func NewCreateAccountCreated() *CreateAccountCreated {
|
||||
account created
|
||||
*/
|
||||
type CreateAccountCreated struct {
|
||||
Payload *rest_model.AccountResponse
|
||||
Payload *rest_model_zrok.AccountResponse
|
||||
}
|
||||
|
||||
func (o *CreateAccountCreated) Error() string {
|
||||
return fmt.Sprintf("[POST /account][%d] createAccountCreated %+v", 201, o.Payload)
|
||||
}
|
||||
func (o *CreateAccountCreated) GetPayload() *rest_model.AccountResponse {
|
||||
func (o *CreateAccountCreated) GetPayload() *rest_model_zrok.AccountResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *CreateAccountCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.AccountResponse)
|
||||
o.Payload = new(rest_model_zrok.AccountResponse)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
@ -15,7 +15,7 @@ import (
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// NewEnableParams creates a new EnableParams object,
|
||||
@ -62,7 +62,7 @@ func NewEnableParamsWithHTTPClient(client *http.Client) *EnableParams {
|
||||
type EnableParams struct {
|
||||
|
||||
// Body.
|
||||
Body *rest_model.EnableRequest
|
||||
Body *rest_model_zrok.EnableRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
@ -118,13 +118,13 @@ func (o *EnableParams) SetHTTPClient(client *http.Client) {
|
||||
}
|
||||
|
||||
// WithBody adds the body to the enable params
|
||||
func (o *EnableParams) WithBody(body *rest_model.EnableRequest) *EnableParams {
|
||||
func (o *EnableParams) WithBody(body *rest_model_zrok.EnableRequest) *EnableParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the enable params
|
||||
func (o *EnableParams) SetBody(body *rest_model.EnableRequest) {
|
||||
func (o *EnableParams) SetBody(body *rest_model_zrok.EnableRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// EnableReader is a Reader for the Enable structure.
|
||||
@ -56,19 +56,19 @@ func NewEnableCreated() *EnableCreated {
|
||||
environment enabled
|
||||
*/
|
||||
type EnableCreated struct {
|
||||
Payload *rest_model.EnableResponse
|
||||
Payload *rest_model_zrok.EnableResponse
|
||||
}
|
||||
|
||||
func (o *EnableCreated) Error() string {
|
||||
return fmt.Sprintf("[POST /enable][%d] enableCreated %+v", 201, o.Payload)
|
||||
}
|
||||
func (o *EnableCreated) GetPayload() *rest_model.EnableResponse {
|
||||
func (o *EnableCreated) GetPayload() *rest_model_zrok.EnableResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *EnableCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.EnableResponse)
|
||||
o.Payload = new(rest_model_zrok.EnableResponse)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
@ -12,7 +12,7 @@ import (
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// VersionReader is a Reader for the Version structure.
|
||||
@ -44,19 +44,19 @@ func NewVersionOK() *VersionOK {
|
||||
retrieve the current server version
|
||||
*/
|
||||
type VersionOK struct {
|
||||
Payload *rest_model.Version
|
||||
Payload *rest_model_zrok.Version
|
||||
}
|
||||
|
||||
func (o *VersionOK) Error() string {
|
||||
return fmt.Sprintf("[GET /version][%d] versionOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *VersionOK) GetPayload() *rest_model.Version {
|
||||
func (o *VersionOK) GetPayload() *rest_model_zrok.Version {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *VersionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.Version)
|
||||
o.Payload = new(rest_model_zrok.Version)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package rest_zrok_client
|
||||
package rest_client_zrok
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
@ -10,8 +10,8 @@ import (
|
||||
httptransport "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_client/identity"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_client/metadata"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/identity"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_client_zrok/metadata"
|
||||
)
|
||||
|
||||
// Default zrok HTTP client.
|
@ -1,110 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package rest_model
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// BaseEntity Fields shared by all zrok entities
|
||||
//
|
||||
// swagger:model baseEntity
|
||||
type BaseEntity struct {
|
||||
|
||||
// created at
|
||||
// Required: true
|
||||
CreatedAt *string `json:"createdAt"`
|
||||
|
||||
// id
|
||||
// Required: true
|
||||
ID *string `json:"id"`
|
||||
|
||||
// updated at
|
||||
// Required: true
|
||||
// Format: date-time
|
||||
UpdatedAt *strfmt.DateTime `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// Validate validates this base entity
|
||||
func (m *BaseEntity) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateCreatedAt(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateID(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateUpdatedAt(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BaseEntity) validateCreatedAt(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("createdAt", "body", m.CreatedAt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BaseEntity) validateID(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("id", "body", m.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BaseEntity) validateUpdatedAt(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("updatedAt", "body", m.UpdatedAt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("updatedAt", "body", "date-time", m.UpdatedAt.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this base entity based on context it is used
|
||||
func (m *BaseEntity) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *BaseEntity) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *BaseEntity) UnmarshalBinary(b []byte) error {
|
||||
var res BaseEntity
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package rest_model
|
||||
package rest_model_zrok
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
@ -1,6 +1,6 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package rest_model
|
||||
package rest_model_zrok
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
@ -1,6 +1,6 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package rest_model
|
||||
package rest_model_zrok
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
@ -1,6 +1,6 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package rest_model
|
||||
package rest_model_zrok
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
@ -1,6 +1,6 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package rest_model
|
||||
package rest_model_zrok
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
@ -1,6 +1,6 @@
|
||||
// This file is safe to edit. Once it exists it will not be overwritten
|
||||
|
||||
package rest_zrok_server
|
||||
package rest_server_zrok
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
@ -9,10 +9,10 @@ import (
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations"
|
||||
)
|
||||
|
||||
//go:generate swagger generate server --target ../../zrok --name Zrok --spec ../specs/zrok.yml --model-package rest_model --server-package rest_zrok_server --principal interface{}
|
||||
//go:generate swagger generate server --target ../../zrok --name Zrok --spec ../specs/zrok.yml --model-package rest_model_zrok --server-package rest_server_zrok --principal interface{} --exclude-main
|
||||
|
||||
func configureFlags(api *operations.ZrokAPI) {
|
||||
// api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... }
|
@ -1,6 +1,6 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Package rest_zrok_server zrok
|
||||
// Package rest_server_zrok zrok
|
||||
//
|
||||
// zrok client access
|
||||
// Schemes:
|
||||
@ -16,4 +16,4 @@
|
||||
// - application/zrok.v1+json
|
||||
//
|
||||
// swagger:meta
|
||||
package rest_zrok_server
|
||||
package rest_server_zrok
|
@ -1,6 +1,6 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package rest_zrok_server
|
||||
package rest_server_zrok
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
@ -14,7 +14,7 @@ import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// NewCreateAccountParams creates a new CreateAccountParams object
|
||||
@ -37,7 +37,7 @@ type CreateAccountParams struct {
|
||||
/*
|
||||
In: body
|
||||
*/
|
||||
Body *rest_model.AccountRequest
|
||||
Body *rest_model_zrok.AccountRequest
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
@ -51,7 +51,7 @@ func (o *CreateAccountParams) BindRequest(r *http.Request, route *middleware.Mat
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body rest_model.AccountRequest
|
||||
var body rest_model_zrok.AccountRequest
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
} else {
|
@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// CreateAccountCreatedCode is the HTTP code returned for type CreateAccountCreated
|
||||
@ -25,7 +25,7 @@ type CreateAccountCreated struct {
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *rest_model.AccountResponse `json:"body,omitempty"`
|
||||
Payload *rest_model_zrok.AccountResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewCreateAccountCreated creates CreateAccountCreated with default headers values
|
||||
@ -35,13 +35,13 @@ func NewCreateAccountCreated() *CreateAccountCreated {
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the create account created response
|
||||
func (o *CreateAccountCreated) WithPayload(payload *rest_model.AccountResponse) *CreateAccountCreated {
|
||||
func (o *CreateAccountCreated) WithPayload(payload *rest_model_zrok.AccountResponse) *CreateAccountCreated {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the create account created response
|
||||
func (o *CreateAccountCreated) SetPayload(payload *rest_model.AccountResponse) {
|
||||
func (o *CreateAccountCreated) SetPayload(payload *rest_model_zrok.AccountResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// NewEnableParams creates a new EnableParams object
|
||||
@ -37,7 +37,7 @@ type EnableParams struct {
|
||||
/*
|
||||
In: body
|
||||
*/
|
||||
Body *rest_model.EnableRequest
|
||||
Body *rest_model_zrok.EnableRequest
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
@ -51,7 +51,7 @@ func (o *EnableParams) BindRequest(r *http.Request, route *middleware.MatchedRou
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body rest_model.EnableRequest
|
||||
var body rest_model_zrok.EnableRequest
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
} else {
|
@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// EnableCreatedCode is the HTTP code returned for type EnableCreated
|
||||
@ -25,7 +25,7 @@ type EnableCreated struct {
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *rest_model.EnableResponse `json:"body,omitempty"`
|
||||
Payload *rest_model_zrok.EnableResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewEnableCreated creates EnableCreated with default headers values
|
||||
@ -35,13 +35,13 @@ func NewEnableCreated() *EnableCreated {
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the enable created response
|
||||
func (o *EnableCreated) WithPayload(payload *rest_model.EnableResponse) *EnableCreated {
|
||||
func (o *EnableCreated) WithPayload(payload *rest_model_zrok.EnableResponse) *EnableCreated {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the enable created response
|
||||
func (o *EnableCreated) SetPayload(payload *rest_model.EnableResponse) {
|
||||
func (o *EnableCreated) SetPayload(payload *rest_model_zrok.EnableResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
|
||||
)
|
||||
|
||||
// VersionOKCode is the HTTP code returned for type VersionOK
|
||||
@ -25,7 +25,7 @@ type VersionOK struct {
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *rest_model.Version `json:"body,omitempty"`
|
||||
Payload *rest_model_zrok.Version `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewVersionOK creates VersionOK with default headers values
|
||||
@ -35,13 +35,13 @@ func NewVersionOK() *VersionOK {
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the version o k response
|
||||
func (o *VersionOK) WithPayload(payload *rest_model.Version) *VersionOK {
|
||||
func (o *VersionOK) WithPayload(payload *rest_model_zrok.Version) *VersionOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the version o k response
|
||||
func (o *VersionOK) SetPayload(payload *rest_model.Version) {
|
||||
func (o *VersionOK) SetPayload(payload *rest_model_zrok.Version) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ import (
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations/identity"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations/metadata"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/identity"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/metadata"
|
||||
)
|
||||
|
||||
// NewZrokAPI creates a new Zrok instance
|
@ -1,6 +1,6 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package rest_zrok_server
|
||||
package rest_server_zrok
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -25,7 +25,7 @@ import (
|
||||
flags "github.com/jessevdk/go-flags"
|
||||
"golang.org/x/net/netutil"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations"
|
||||
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations"
|
||||
)
|
||||
|
||||
const (
|
@ -1,126 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package metadata
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewGetParams creates a new GetParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewGetParams() *GetParams {
|
||||
return &GetParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetParamsWithTimeout creates a new GetParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewGetParamsWithTimeout(timeout time.Duration) *GetParams {
|
||||
return &GetParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetParamsWithContext creates a new GetParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewGetParamsWithContext(ctx context.Context) *GetParams {
|
||||
return &GetParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetParamsWithHTTPClient creates a new GetParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewGetParamsWithHTTPClient(client *http.Client) *GetParams {
|
||||
return &GetParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/* GetParams contains all the parameters to send to the API endpoint
|
||||
for the get operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type GetParams struct {
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the get params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *GetParams) WithDefaults() *GetParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the get params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *GetParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the get params
|
||||
func (o *GetParams) WithTimeout(timeout time.Duration) *GetParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the get params
|
||||
func (o *GetParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the get params
|
||||
func (o *GetParams) WithContext(ctx context.Context) *GetParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the get params
|
||||
func (o *GetParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the get params
|
||||
func (o *GetParams) WithHTTPClient(client *http.Client) *GetParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the get params
|
||||
func (o *GetParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *GetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package metadata
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
)
|
||||
|
||||
// GetReader is a Reader for the Get structure.
|
||||
type GetReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *GetReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewGetOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetOK creates a GetOK with default headers values
|
||||
func NewGetOK() *GetOK {
|
||||
return &GetOK{}
|
||||
}
|
||||
|
||||
/* GetOK describes a response with status code 200, with default header values.
|
||||
|
||||
retrieve the current server version
|
||||
*/
|
||||
type GetOK struct {
|
||||
Payload *rest_model.Version
|
||||
}
|
||||
|
||||
func (o *GetOK) Error() string {
|
||||
return fmt.Sprintf("[GET /][%d] getOK %+v", 200, o.Payload)
|
||||
}
|
||||
func (o *GetOK) GetPayload() *rest_model.Version {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model.Version)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package metadata
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// GetHandlerFunc turns a function with the right signature into a get handler
|
||||
type GetHandlerFunc func(GetParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetHandlerFunc) Handle(params GetParams) middleware.Responder {
|
||||
return fn(params)
|
||||
}
|
||||
|
||||
// GetHandler interface for that can handle valid get params
|
||||
type GetHandler interface {
|
||||
Handle(GetParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGet creates a new http.Handler for the get operation
|
||||
func NewGet(ctx *middleware.Context, handler GetHandler) *Get {
|
||||
return &Get{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* Get swagger:route GET / metadata get
|
||||
|
||||
Get get API
|
||||
|
||||
*/
|
||||
type Get struct {
|
||||
Context *middleware.Context
|
||||
Handler GetHandler
|
||||
}
|
||||
|
||||
func (o *Get) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewGetParams()
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package metadata
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
)
|
||||
|
||||
// NewGetParams creates a new GetParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewGetParams() GetParams {
|
||||
|
||||
return GetParams{}
|
||||
}
|
||||
|
||||
// GetParams contains all the bound params for the get operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters Get
|
||||
type GetParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
}
|
||||
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewGetParams() beforehand.
|
||||
func (o *GetParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package metadata
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||
)
|
||||
|
||||
// GetOKCode is the HTTP code returned for type GetOK
|
||||
const GetOKCode int = 200
|
||||
|
||||
/*GetOK retrieve the current server version
|
||||
|
||||
swagger:response getOK
|
||||
*/
|
||||
type GetOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *rest_model.Version `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetOK creates GetOK with default headers values
|
||||
func NewGetOK() *GetOK {
|
||||
|
||||
return &GetOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get o k response
|
||||
func (o *GetOK) WithPayload(payload *rest_model.Version) *GetOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get o k response
|
||||
func (o *GetOK) SetPayload(payload *rest_model.Version) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package metadata
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
)
|
||||
|
||||
// GetURL generates an URL for the get operation
|
||||
type GetURL struct {
|
||||
_basePath string
|
||||
}
|
||||
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *GetURL) WithBasePath(bp string) *GetURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *GetURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *GetURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/"
|
||||
|
||||
_basePath := o._basePath
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *GetURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *GetURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *GetURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on GetURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on GetURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *GetURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
Loading…
Reference in New Issue
Block a user