Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Endpoint Configuration

Endpoint configuration determines which request path Flux.REST uses for each operation in a Set Context.

Configuration Precedence

When multiple configuration rules apply to a single endpoint, a rule with the most specific set of HTTP verbs and operational constraints will take precedence.

To demonstrate endpoint configuration precedence, suppose a school API uses separate paths for retrieving and managing students:

HTTP methodRequest path
GET/courses/{courseId}/students?offset={offset}&limit={limit}
GET/students/{id}
POST/management/students
PUT/management/students/{id}
DELETE/management/students/{id}

Configure Flux

The Student Set has three endpoint configurations:

.AddSet<Student, int>()
    .WithEndpoint("management/students")
    .WithGet("students")
    .WithGet((PageRequest _) => "courses/{{courseId}}/students")
  • WithGet("students") takes precedence over WithEndpoint("management/students") for the Get operation because it applies only to GET verb.
  • WithGet((PageRequest _) => "courses/{courseId}/students") takes precedence over WithGet("students") because it applies specifically to the Get Page operation because of the PageRequest operational constraint.
  • WithEndpoint("management/students") specifies the base path, which is then used in Add, Update, and Remove operations.

Tip

See the other available endpoint configuration method overloads.

Sample operations

Example operations that can be performed using the configuration as shown above:

HTTP methodRequest pathConfigurationUsage
GET/courses/{courseId}/students?offset={offset}&limit={limit}.WithGet((PageRequest _) => "courses/{courseId}/students").GetPageAsync(offset: 0, limit: 20, parameters: parameters)
GET/students/{id}.WithGet("students").GetAsync(42)
POST/management/students.WithEndpoint("management/students").AddAsync(newStudent)
PUT/management/students/{id}.WithEndpoint("management/students").UpdateAsync(updatedStudent, 42)
DELETE/management/students/{id}.WithEndpoint("management/students").RemoveAsync(42)