Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backmerge 31 03 2022 #1171

Merged
merged 175 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
0ffb4d6
Doc: Add outline (#815)
girdharshubham Jan 12, 2022
6410f7e
Update netty-all to 4.1.73.Final (#811)
d11-amitsingh Jan 12, 2022
3a34823
Disable benchmarks comment on fork pull request (#820)
d11-amitsingh Jan 13, 2022
66a1dea
Feature: API to modify headers (#824)
ShrutiVerma97 Jan 13, 2022
143ad28
Feature: Signed Cookie (#751)
ShrutiVerma97 Jan 13, 2022
67650c2
Update sbt-scalafix to 0.9.34 (#805)
d11-amitsingh Jan 13, 2022
64a8f4a
Fix: Echo streaming (#828)
d11-amitsingh Jan 14, 2022
72d71d3
Docs: Update Basic Examples (#814)
ShrutiVerma97 Jan 14, 2022
569bd1d
docs: update advanced examples (#816)
ShrutiVerma97 Jan 14, 2022
fa47791
maintenance: semanticdb revision usage (#832)
girdharshubham Jan 14, 2022
10df2c6
maintenance: workflow scala version (#833)
girdharshubham Jan 14, 2022
9c77c03
Fix: HasHeader bug (#835)
gciuloaica Jan 15, 2022
9ee2048
refactor: fix naming for Http operators (#839)
Jan 15, 2022
3c56a90
Update sbt-bloop to 1.4.12 (#810)
d11-amitsingh Jan 15, 2022
da7c459
Update scala-library to 2.13.8 (#801)
d11-amitsingh Jan 15, 2022
dfd11ac
Add configuration builder methods to zhttp.service.Server (#768)
jgoday Jan 15, 2022
134a9b5
maintenance: html template for internal server error string (#851)
girdharshubham Jan 18, 2022
13c7d2b
Performance: Improve benchmarking code (#731)
Jan 18, 2022
e9abd9f
Refactor: Support middlewares on Http (#773)
Jan 18, 2022
9fc4f40
refactor: rename ClientParams to ClientRequest (#856)
Jan 20, 2022
3b9ea3a
refactor: use declarative encoding for http.middleware (#869)
brendo-m Jan 21, 2022
ecc3d8a
Move docs to v1.x directory (#861)
d11-amitsingh Jan 21, 2022
b9784ac
Bug Add host in client from absolute URL (#847)
D11Kaushik Jan 21, 2022
a36afbc
Doc website fix (#871)
d11-amitsingh Jan 21, 2022
bcbcdd3
Update scala3-library to 3.1.1 (#873)
d11-amitsingh Jan 21, 2022
9e8544c
Doc: Fix getting started link (#874)
d11-amitsingh Jan 21, 2022
a870231
Update scalafmt-core to 3.3.2 (#864)
d11-amitsingh Jan 21, 2022
bdae5cf
Doc: `Headers` documentation (#817)
gciuloaica Jan 21, 2022
786f51a
Fix collapsible Headers Doc (#876)
d11-amitsingh Jan 22, 2022
9fbabe5
Test: Added Integration tests for `HExit.Success` (#852)
zsfVishnu-d11 Jan 24, 2022
0d59e4c
Update scalafmt-core to 3.3.3 (#881)
scala-steward Jan 24, 2022
e4d7424
Update scalafmt-core to 3.3.3 (#884)
d11-amitsingh Jan 24, 2022
0ee6dde
Fix: EncodeClientParams (#868)
ShrutiVerma97 Jan 24, 2022
dc0d80f
Refactor: HttpRunnableSpec clean up (#857)
Jan 25, 2022
6850897
update doc (#897)
Jan 26, 2022
14320ef
Docs: Getting started (#887)
ShrutiVerma97 Jan 26, 2022
fe4424e
refactor: rename asString to encode in URI (#898)
Jan 26, 2022
9d30a44
refactor: rename asString to encode in Scheme (#904)
Jan 26, 2022
470206b
fix: example links (#906)
ShrutiVerma97 Jan 26, 2022
23011a9
Update getting-started.md (#907)
d11-amitsingh Jan 26, 2022
d58857c
refactor: rename asString to encode in Scheme (#905)
Jan 26, 2022
f75030c
Doc: setup (#886)
girdharshubham Jan 26, 2022
5e714e0
Update netty-incubator-transport-native-io_uring to 0.0.12.Final (#908)
scala-steward Jan 27, 2022
b656936
Documentation for Server (#885)
sumawa Jan 27, 2022
594d8cb
Performance: Improve performance of `collectM` (#882)
Jan 27, 2022
b54e935
Doc: Added <> operator in getting started (#910)
ShrutiVerma97 Jan 27, 2022
8e73e9e
feature: Add `collectManaged` to Http (#909)
beem812 Jan 27, 2022
0a3d486
feature: add `echo` operator to `Socket` (#900)
Jan 27, 2022
cfa6c3e
feature: add `Socket.empty` (#901)
Jan 27, 2022
36f8c83
feature: add `toHttp` to Socket.scala (#902)
Jan 27, 2022
fc8b9b5
refactor: merge Request for Client and Server (#894)
Jan 27, 2022
91db176
Revert "refactor: merge Request for Client and Server (#894)" (#915)
Jan 28, 2022
d88c0c4
Feature: add `toHttp` to Response (#903)
Jan 28, 2022
4e2d48c
Update scalafmt-core to 3.4.0 (#920)
d11-amitsingh Feb 1, 2022
7d5a80f
Update sbt to 1.6.2 (#931)
scala-steward Feb 1, 2022
d8b0143
Remove outdated benchmark.md (#940)
ShrutiVerma97 Feb 1, 2022
120450b
refactor: rename `getHeaders` to `headers` in `ClientRequest` (#928)
Feb 1, 2022
aec7382
Refactor: rename `asString` to `encode` in `Path` (#927)
Feb 1, 2022
21cdee6
Disable flow Control (#854)
d11-amitsingh Feb 1, 2022
b192d89
Add builder pattern for URL (#930)
beem812 Feb 2, 2022
c1a306e
Documentation: Http (#888)
dinojohn Feb 2, 2022
456d198
feature: add `Http.apply` (#949)
Feb 3, 2022
95cddc3
Refactor: Drop `toZIO` and `wrapZIO` APIs (#950)
Feb 3, 2022
7873444
Fix: Server KeepAlive true by default and enable client to set Http v…
sumawa Feb 3, 2022
ad3cf22
feat: url add `isAbsolute` and `isRelative` operators (#946)
Feb 3, 2022
3a7e14f
WebSocket Client Support (#933)
tusharmath Feb 4, 2022
ef63c23
Documentation: Request (#926)
ShrutiVerma97 Feb 4, 2022
f396f17
Fix ssl issue due to missing peer host port hint (#952)
d11-amitsingh Feb 5, 2022
e514484
feature: add connect operator on Socket (#955)
tusharmath Feb 5, 2022
6e9c007
Style: Update scala doc wrapping (#959)
tusharmath Feb 5, 2022
b679318
remove get prefix (#958)
tusharmath Feb 5, 2022
136de3e
Update scalafmt-core to 3.4.1 (#960)
scala-steward Feb 6, 2022
2455df1
Update scalafmt-core to 3.4.2 (#962)
scala-steward Feb 6, 2022
e6925b2
Update scalafmt-core to 3.4.2 (#961)
d11-amitsingh Feb 6, 2022
c2ed52e
remove declarative API (#957)
tusharmath Feb 7, 2022
88e2c70
Update sbt-updates to 0.6.2 (#966)
scala-steward Feb 8, 2022
047944f
Doc: Readme (#970)
ShrutiVerma97 Feb 8, 2022
d3fa639
style: rearrange methods in files (#963)
tusharmath Feb 8, 2022
5e4a0cf
Doc: Cookie (#974)
ShrutiVerma97 Feb 8, 2022
b538a1d
refactor: drop `CanBeSilent` type-constraint from Http (#964)
tusharmath Feb 8, 2022
d1d917c
Feature: add `Version` (#965)
tusharmath Feb 8, 2022
ab96fdb
Fix: Fire response instead of error in HExit.Failure() (#980)
dinojohn Feb 8, 2022
9c9fd5e
fix: typo in bug_report.md (#981)
dinojohn Feb 8, 2022
2a73a95
Update netty-all to 4.1.74.Final (#982)
scala-steward Feb 9, 2022
0c0fda2
refactor: remove sealed modifier from Middleware trait (#984)
tusharmath Feb 9, 2022
4b760b4
refactor: rename method on Client (#985)
tusharmath Feb 9, 2022
7fd68ed
fix: request doc (#989)
ShrutiVerma97 Feb 9, 2022
b16b79f
Use a Gen of methods without HEAD for Responses with content (#992)
dinojohn Feb 9, 2022
e94ba3f
doc: setup g8 (#988)
girdharshubham Feb 9, 2022
1571c71
Doc: for WebSocketFrame (#953)
girdharshubham Feb 9, 2022
2bb5fd5
Documentation for HttpData (#987)
dinojohn Feb 10, 2022
88a29c3
refactor: rename `provide` and `provideSome` (#996)
girdharshubham Feb 10, 2022
35e6e32
Fix: `Content-Type` header gets incorrect values. (#899)
ashprakasan Feb 10, 2022
9ada314
Feat: Http from HExit (#986)
dinojohn Feb 10, 2022
259f171
Refactor: Remove Collect and FromFunctionZIO (#1002)
dinojohn Feb 10, 2022
0946576
Fix: Binary WebSocketFrame (#1005)
girdharshubham Feb 10, 2022
8ef998c
feature: add `fromFileZIO` (#1010)
tusharmath Feb 10, 2022
1b2e629
refactor: `fromFile` uses `fromFileZIO`
tusharmath Feb 10, 2022
f22f788
feature: add `Http.fromResource` (#1009)
tusharmath Feb 10, 2022
0ef5c29
Refactor: Content Type Fixes (#1008)
tusharmath Feb 10, 2022
61932ef
doc: fix binary constructor usage (#1014)
girdharshubham Feb 10, 2022
835f9aa
Add data in `Request` trait (#1017)
d11-amitsingh Feb 11, 2022
660d80e
maintenance: run scalafmt once (#1027)
girdharshubham Feb 14, 2022
0f906fd
Build(deps): Bump follow-redirects in /docs/website (#1029)
dependabot[bot] Feb 15, 2022
9f2fa84
Update scalafmt-core to 3.4.3 (#1022)
d11-amitsingh Feb 15, 2022
61e57a0
Remove tuple from ResponseHandler (#1033)
d11-amitsingh Feb 16, 2022
93701cd
restructuring (#1040)
ShrutiVerma97 Feb 17, 2022
70585bd
added more examples (#1038)
ShrutiVerma97 Feb 17, 2022
3f6894e
Doc: Response (#967)
ShrutiVerma97 Feb 17, 2022
77513ce
renaming (#1047)
ShrutiVerma97 Feb 17, 2022
fea9f23
Fix: Releasing request twice (#1046)
dinojohn Feb 17, 2022
b57aa88
optimize path encode method (#1035)
ShrutiVerma97 Feb 18, 2022
33ac08d
Feature: Static Server (#1024)
tusharmath Feb 19, 2022
84d5799
Revert "Feature: Static Server (#1024)" (#1060)
tusharmath Feb 19, 2022
cc22195
Performance: Use `CharSequence` for ServerTime (#1064)
tusharmath Feb 20, 2022
3e6d34c
Feature: add `dropLast` to Path (#1065)
tusharmath Feb 20, 2022
d59c005
feature: Response.html now supports taking in Status also (#1067)
tusharmath Feb 20, 2022
6cdf6c3
feature: add `code` method on Status (#1068)
tusharmath Feb 20, 2022
e0e413b
refactor: fix type info of `Http.response` (#1073)
tusharmath Feb 20, 2022
2aed79e
feature: add `foldCause` to HttpError (#1066)
tusharmath Feb 20, 2022
24a778c
feature: add `withMediaType` operator in HeaderModifier (#1071)
tusharmath Feb 20, 2022
32d29e0
Feature: add `Http.attempt` operator (#1070)
tusharmath Feb 20, 2022
e4e42fb
feature: add `getResource` and `getResourceAsFile` operators on Http …
tusharmath Feb 20, 2022
1564ed1
Update jwt-core to 9.0.4 (#1056)
d11-amitsingh Feb 20, 2022
0f5412f
Update sbt-bloop to 1.4.13 (#1055)
d11-amitsingh Feb 20, 2022
335dcd5
Build(deps): Bump url-parse from 1.5.4 to 1.5.7 in /docs/website (#1062)
dependabot[bot] Feb 20, 2022
f139ded
feature: add `ifModifiedSinceDecoded` (#1075)
tusharmath Feb 20, 2022
33fb57a
Feature: Static Server (#1061)
tusharmath Feb 20, 2022
29c37c6
issue 715 Support custom ChannelInitializer (#932)
rajcspsg Feb 20, 2022
f632f58
doc: socket (#1036)
girdharshubham Feb 21, 2022
042291a
feat: added new constructor in http (#1077)
ShrutiVerma97 Feb 23, 2022
9914695
Feature: Add `when` operator in `Http` (#1078)
ShrutiVerma97 Feb 24, 2022
8cea811
Feature: Effectful Auth Middleware (#1079)
dinojohn Feb 24, 2022
06c29d2
Test: Server Settings Support in `HttpRunnableSpec#serve` (#1053)
girdharshubham Feb 24, 2022
7f9b409
refactor: website docs sidebar pages repositioned (#1049)
girdharshubham Feb 25, 2022
a9ae523
Feat: Server Request Decompression (#1095)
girdharshubham Feb 25, 2022
0096ea9
Feature: Added helper checkers to `Status` class (#1058)
rleibman Feb 25, 2022
4ddc855
Build(deps): Bump prismjs from 1.26.0 to 1.27.0 in /docs/website (#1100)
dependabot[bot] Feb 28, 2022
7cc3555
Build(deps): Bump url-parse from 1.5.7 to 1.5.10 in /docs/website (#1…
dependabot[bot] Feb 28, 2022
ecffdff
added try catch in handler to catch throwable apps (#1099)
dinojohn Feb 28, 2022
69788f3
removed flatten from test (#1109)
ShrutiVerma97 Mar 1, 2022
8e4f6bf
Feature: Request Streaming (#1048)
d11-amitsingh Mar 1, 2022
2bbeb9b
Fix toByteBuf for streamed HttpData (#1118)
ex0ns Mar 5, 2022
0dca97d
example: more secure string compare for login (#1120)
MasseGuillaume Mar 7, 2022
dc33298
Feature: Introduced defect channel for `Http` (#1083)
nartamonov Mar 7, 2022
d603324
Enhancement: Merge server and client Responses (#1111)
d11-amitsingh Mar 7, 2022
48ce70c
rename getBodyAsString => bodyAsString in doc (#1124)
MasseGuillaume Mar 8, 2022
37657eb
removed links from scaladoc (#1127)
dinojohn Mar 8, 2022
c1d98ea
Feature: Add `version` to `Request` (#1094)
d11-amitsingh Mar 9, 2022
94be6b9
Refactor: Merge client and server `Request` (#1125)
d11-amitsingh Mar 9, 2022
5069856
Refactor: Http.Status names to Camel Case (#1129)
tusharmath Mar 10, 2022
0de7b80
Feature: Support Custom statuses code (#1121)
gciuloaica Mar 10, 2022
006e318
Enhancement: Added combine operator (#1106)
ShrutiVerma97 Mar 10, 2022
b3613d2
Refactor: Added lift in PartialCollect (#1105)
ShrutiVerma97 Mar 10, 2022
ec62037
Feature: Bearer auth middleware (#1097)
dinojohn Mar 10, 2022
4cab597
Update netty-all to 4.1.75.Final (#1130)
scala-steward Mar 10, 2022
15e9920
Refactor: `Request` and `Response` to extend `HttpDataExtension` (#1112)
d11-amitsingh Mar 10, 2022
cf299f4
Refactor: Make `Http.getResource` consistent with `ZStream.fromResour…
guizmaii Mar 13, 2022
f18e0ef
Update netty-incubator-transport-native-io_uring to 0.0.13.Final (#1133)
scala-steward Mar 14, 2022
061abe5
Add more useful toString method for Request (#995)
nartamonov Mar 16, 2022
6aa1aef
fix(request): fix scala doc (#1138)
D11Kaushik Mar 16, 2022
2f47081
Performance: Improve HttpData toByteBuf (#1137)
tusharmath Mar 20, 2022
6e5008a
Fix: Handle HttpClient Interruption on connection close (#1039)
gciuloaica Mar 21, 2022
c24c67b
New chapter: efficient development process (#1145)
DaniRey Mar 21, 2022
97c3eaf
do not watch reStop (#1146)
DaniRey Mar 21, 2022
91a0558
Feature: add `Middleware.codecHttp` (#1141)
tusharmath Mar 25, 2022
fe48544
Performance: Use `CharSequence` internally wherever possible (#1142)
tusharmath Mar 26, 2022
55b28fd
Update scala-collection-compat to 2.7.0 (#1154)
d11-amitsingh Mar 26, 2022
57e576b
Update jwt-core to 9.0.5 (#1150)
d11-amitsingh Mar 26, 2022
0a5c0c8
feature: add `narrow` operator to Http (#1161)
tusharmath Mar 27, 2022
2114ccb
feature: add `toHttp` method to `Response` (#1160)
tusharmath Mar 27, 2022
71a5b0a
refactor: DynamicServer is not bound to HttpEnv only (#1159)
tusharmath Mar 28, 2022
568dfb6
fix: Socket.end implementation (#1158)
tusharmath Mar 28, 2022
d978571
Update sbt-scala3-migrate to 0.5.1 (#1163)
d11-amitsingh Mar 30, 2022
1bd42c8
Merge remote-tracking branch 'origin/main' into backmerge-31-03-2022
amitksingh1490 Apr 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 0 additions & 133 deletions docs/website/docs/getting-started.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/website/docs/v1.x/dsl/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ The below snippet tests an app that takes `Int` as input and responds by adding
object Spec extends DefaultRunnableSpec {

def spec = suite("http")(
test("1 + 1 = 2") {
testM("1 + 1 = 2") {
val app: Http[Any, Nothing, Int, Int] = Http.fromFunction[Int](_ + 1)
assertM(app(1))(equalTo(2))
}
Expand Down
4 changes: 2 additions & 2 deletions docs/website/docs/v1.x/dsl/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This section describes, ZIO HTTP Server and different configurations you can pro
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = {
server.make
.use(start =>
Console.printLine(s"Server started on port ${start.port}")
console.putStrLn(s"Server started on port ${start.port}")
*> ZIO.never,
).provideCustomLayer(ServerChannelFactory.auto ++ EventLoopGroup.auto(2))
.exitCode
Expand Down Expand Up @@ -84,7 +84,7 @@ object HelloWorldAdvanced extends App {
server.make
.use(_ =>
// Waiting for the server to start
Console.printLine(s"Server started on port $PORT")
console.putStrLn(s"Server started on port $PORT")

// Ensures the server doesn't die after printing
*> ZIO.never,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object HelloWorldAdvanced extends App {
server.make
.use(start =>
// Waiting for the server to start
Console.printLine(s"Server started on port ${start.port}")
console.putStrLn(s"Server started on port ${start.port}")

// Ensures the server doesn't die after printing
*> ZIO.never,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object HttpsClient extends App {
val program = for {
res <- Client.request(url, headers, sslOption)
data <- res.bodyAsString
_ <- Console.printLine { data }
_ <- console.putStrLn { data }
} yield ()

override def run(args: List[String]): URIO[zio.ZEnv, ExitCode]
Expand Down
2 changes: 1 addition & 1 deletion docs/website/docs/v1.x/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ import zhttp.http._
object Spec extends DefaultRunnableSpec {

def spec = suite("http")(
test("should be ok") {
testM("should be ok") {
val app = Http.ok
val req = Request()
assertM(app(req))(equalTo(Response.ok))
Expand Down
33 changes: 33 additions & 0 deletions docs/website/docs/v1.x/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,36 @@ sbt new dream11/zio-http.g8
* [scalafix-organize-imports](https://github.com/liancheng/scalafix-organize-imports)
* [sbt-revolver](https://github.com/spray/sbt-revolver)

## Efficient development process

The dependencies in the Dream11 g8 template were added to enable an efficient development process.

### sbt-revolver "hot-reload" changes

Sbt-revolver can watch application resources for change and automatically re-compile and then re-start the application under development. This provides a fast development-turnaround, the closest you can get to real hot-reloading.

Start your application from _sbt_ with the following command

```shell
~reStart
```

Pressing enter will stop watching for changes, but not stop the application. Use the following command to stop the application (shutdown hooks will not be executed).

```
reStop
```

In case you already have an _sbt_ server running, i.e. to provide your IDE with BSP information, use _sbtn_ instead of _sbt_ to run `~reStart`, this let's both _sbt_ sessions share one server.

### scalafmt automatically format source code

scalafmt will automatically format all source code and assert that all team members use consistent formatting.

### scalafix refactoring and linting

scalafix will mainly be used as a linting tool during everyday development, for example by removing unused dependencies or reporting errors for disabled features. Additionally it can simplify upgrades of Scala versions and dependencies, by executing predefined migration paths.

### sbt-native-packager

sbt-native-packager can package the application in the most popular formats, for example Docker images, rpm packages or graalVM native images.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package example

import io.netty.util.AsciiString
import zhttp.http._
import zhttp.http.{Http, _}
import zhttp.service.server.ServerChannelFactory
import zhttp.service.{EventLoopGroup, Server}
import zio.{ExitCode, UIO, URIO, ZIOAppDefault}
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object Dependencies {
val JwtCoreVersion = "9.0.4"
val NettyVersion = "4.1.75.Final"
val NettyIncubatorVersion = "0.0.13.Final"
val ScalaCompactCollectionVersion = "2.6.0"
val ScalaCompactCollectionVersion = "2.7.0"
val ZioVersion = "2.0.0-RC2"
val SttpVersion = "3.3.18"

Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.2")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scala3-migrate" % "0.5.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scala3-migrate" % "0.5.1")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
14 changes: 7 additions & 7 deletions zio-http/src/main/scala/zhttp/html/Dom.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package zhttp.html
* elements.
*/
sealed trait Dom { self =>
def encode: String = self match {
def encode: CharSequence = self match {
case Dom.Element(name, children) =>
val attributes = children.collect { case self: Dom.Attribute => self.encode }

Expand All @@ -35,19 +35,19 @@ sealed trait Dom { self =>
}

object Dom {
def attr(name: String, value: String): Dom = Dom.Attribute(name, value)
def attr(name: CharSequence, value: CharSequence): Dom = Dom.Attribute(name, value)

def element(name: String, children: Dom*): Dom = Dom.Element(name, children)
def element(name: CharSequence, children: Dom*): Dom = Dom.Element(name, children)

def empty: Dom = Empty

def text(data: String): Dom = Dom.Text(data)
def text(data: CharSequence): Dom = Dom.Text(data)

private[zhttp] final case class Element(name: String, children: Seq[Dom]) extends Dom
private[zhttp] final case class Element(name: CharSequence, children: Seq[Dom]) extends Dom

private[zhttp] final case class Text(data: String) extends Dom
private[zhttp] final case class Text(data: CharSequence) extends Dom

private[zhttp] final case class Attribute(name: String, value: String) extends Dom
private[zhttp] final case class Attribute(name: CharSequence, value: CharSequence) extends Dom

private[zhttp] object Empty extends Dom
}
6 changes: 3 additions & 3 deletions zio-http/src/main/scala/zhttp/html/Elements.scala
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ trait Elements {
}

object Element {
private[zhttp] val voidElementNames: Set[String] =
private[zhttp] val voidElementNames: Set[CharSequence] =
Set(area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr).map(_.name)

private[zhttp] def isVoid(name: String): Boolean = voidElementNames.contains(name)
private[zhttp] def isVoid(name: CharSequence): Boolean = voidElementNames.contains(name)

case class PartialElement(name: String) {
case class PartialElement(name: CharSequence) {
def apply(children: Html*): Dom = Dom.element(
name,
children.collect {
Expand Down
4 changes: 2 additions & 2 deletions zio-http/src/main/scala/zhttp/html/Html.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import scala.language.implicitConversions
* A view is a domain that used generate HTML.
*/
sealed trait Html { self =>
def encode: String = {
def encode: CharSequence = {
self match {
case Html.Empty => ""
case Html.Single(element) => element.encode
Expand All @@ -16,7 +16,7 @@ sealed trait Html { self =>
}

object Html {
implicit def fromString(string: String): Html = Html.Single(Dom.text(string))
implicit def fromString(string: CharSequence): Html = Html.Single(Dom.text(string))

implicit def fromSeq(elements: Seq[Dom]): Html = Html.Multiple(elements)

Expand Down
2 changes: 1 addition & 1 deletion zio-http/src/main/scala/zhttp/html/Template.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package zhttp.html
*/
object Template {

def container(heading: String)(element: Html): Html = {
def container(heading: CharSequence)(element: Html): Html = {
html(
head(
title(s"ZIO Http - ${heading}"),
Expand Down
Loading