-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
139 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
package cask.endpoints | ||
|
||
import cask.internal.Router | ||
import cask.model.ParamContext | ||
import cask.model.{Cookie, Request} | ||
import io.undertow.server.HttpServerExchange | ||
import io.undertow.server.handlers.form.{FormData, FormParserFactory} | ||
|
||
abstract class ParamReader[T] extends Router.ArgReader[Unit, T, cask.model.ParamContext]{ | ||
abstract class ParamReader[T] extends Router.ArgReader[Unit, T, cask.model.Request]{ | ||
def arity: Int | ||
def read(ctx: cask.model.ParamContext, label: String, v: Unit): T | ||
def read(ctx: cask.model.Request, label: String, v: Unit): T | ||
} | ||
object ParamReader{ | ||
class NilParam[T](f: (ParamContext, String) => T) extends ParamReader[T]{ | ||
class NilParam[T](f: (Request, String) => T) extends ParamReader[T]{ | ||
def arity = 0 | ||
def read(ctx: cask.model.ParamContext, label: String, v: Unit): T = f(ctx, label) | ||
def read(ctx: cask.model.Request, label: String, v: Unit): T = f(ctx, label) | ||
} | ||
implicit object HttpExchangeParam extends NilParam[HttpServerExchange]((ctx, label) => ctx.exchange) | ||
|
||
implicit object FormDataParam extends NilParam[FormData]((ctx, label) => | ||
FormParserFactory.builder().build().createParser(ctx.exchange).parseBlocking() | ||
) | ||
|
||
implicit object RequestParam extends NilParam[Request]((ctx, label) => ctx) | ||
|
||
implicit object CookieParam extends NilParam[Cookie]((ctx, label) => | ||
Cookie.fromUndertow(ctx.exchange.getRequestCookies().get(label)) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.