ArgCV

  • Home
  • Code
    • Snippets
  • Life
  • About
  • Gallery
  • Guestbook
  • RSS

http

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.

(more…)

By Yu, 6 years2 years ago
Code

scala 从 url 中读取内容

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

最简单的是Source.fromURL

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>
....

(more…)

By Yu, 10 years2 years ago
  • Home
  • About
  • Guestbook
  • Privacy Policy
Hesmod | Developed by ThemeIsle, Revised by ArgCV