-
Notifications
You must be signed in to change notification settings - Fork 14
EndpointGroup
Josh Wright edited this page Jan 14, 2021
·
4 revisions
An EndpointGroup
represents a collection of endpoints from the
same host.
open class EndpointGroup
The baseURL
represents the shared base URL of all endpoints in
this group. An Endpoint
must be defined as a property of an
EndpointGroup
in order to properly inherit its baseURL
.
Usage:
final class UsersService: EndpointGroup {
@POST("/users")
var createUser: Endpoint<CreateUserRequest, UserDTO>
@GET("/users/:userID")
var getUser: Endpoint<GetUserRequest, UserDTO>
@GET("/users/friends")
var getFriends: Endpoint<Empty, [UserDTO]>
}
let users = UsersService(baseURL: "https://api.my-app.com")
// The baseURL of this request is inferred to be
// `https://api.my-app.com`
users.createUser.request(CreateUserRequest(...))
... // platform specific code for handling the response of
// type `UserDTO`
In this example, all the endpoints above will be requested from
the baseURL of the UsersService
isntance, in this case
https://api.my-app.com
.
Ensure that all defined Endpoint
s are properties of an
EndpointGroup
type so that their baseURL
can be
automatically inferred when they are requested.
Initialize a group with a base url.
public init(baseURL: String)
- baseURL: The
baseURL
for allEndpoint
s defined in this group.
The base URL for all Endpoint
s defined in this group.
let baseURL: String
Generated at 2021-01-13T22:24:59-0800 using swift-doc 1.0.0-beta.5.
Alchemy
Types
- AlterTableBuilder
- BCryptDigest
- BasicAuthMiddleware
- BcryptError
- BelongsToRelationship
- CORSMiddleware
- CORSMiddleware.AllowOriginSetting
- CORSMiddleware.Configuration
- ColumnType
- CreateColumn
- CreateColumnBuilder
- CreateIndex
- CreateTableBuilder
- DatabaseConfig
- DatabaseError
- DatabaseField
- DatabaseKeyMappingStrategy
- DatabaseValue
- DayUnit
- Env
- FrequencyTyped
- Grammar
- HTTPAuth
- HTTPAuth.Basic
- HTTPAuth.Bearer
- HTTPBody
- HTTPError
- HasManyRelationship
- HasOneRelationship
- HasRelationship
- HourUnit
- JoinClause
- JoinType
- Launch
- Log
- MIMEType
- MinuteUnit
- ModelQuery
- MySQLDatabase
- Operator
- OrderClause
- OrderClause.Sort
- OrderedDictionary
- PapyrusClientError
- PathParameter
- PathParameter.DecodingError
- PostgresDatabase
- Query
- Request
- Response
- Router
- RuneError
- SQL
- SQLJSON
- Scheduler
- Schema
- SecondUnit
- Services
- Socket
- StaticFileMiddleware
- StringLength
- Thread
- TokenAuthMiddleware
- WeekUnit
- Weekday
- WhereBoolean
- WhereColumn
- WhereIn
- WhereIn.InType
- WhereNested
- WhereRaw
- WhereValue