Tag

http

2 posts

Code

Gracefully shutdown a http server in golang

To gracefully shutdown a http server requires a few steps.

The http library's serving function will block over there when getting started, until we call http.Server.Close(). As for us, we can invoke the starting function in a goroutine, and call close in another one.

Code

scala 从 url 中读取内容

如前文所说,scala的Source类自带各种输入,除了文件,也可以从url中获得数据.

最简单的是Source.fromURL

Scala
scala> scala.io.Source.fromURL("http://argcv.com").mkString
res1: String =
<!DOCTYPE html>
<html lang="en-US">
<head>
	<title>argcv | enjoy code, enjoy life.</title>
....